Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(Un-)Subscribe a topic will always return an error #473

Closed
3 tasks done
commanderk33n opened this issue Jul 30, 2020 · 1 comment
Closed
3 tasks done

(Un-)Subscribe a topic will always return an error #473

commanderk33n opened this issue Jul 30, 2020 · 1 comment
Labels
android Relates to Android platform bug Something isn't working properly runtime issue An issue related to app runtime

Comments

@commanderk33n
Copy link

commanderk33n commented Jul 30, 2020

Bug report

CHECKLIST

  • I have reproduced the issue using the example project or provided the necessary information to reproduce the issue.

if i use

   FirebasePlugin.subscribe("latest_news", function(){
        console.log("Subscribed to topic");
    }, function(error){
        console.error("Error subscribing to topic: " + error);
    });

get always error callback, even if the (un-) subscription was successful

  • I have checked that no similar issues (open or closed) already exist.

Current behavior:

(Un-)Subscribe a topic will always return an error

Empty cordova project with the plugin

Expected behavior:

no error, successful return

Steps to reproduce:

use

   FirebasePlugin.subscribe("latest_news", function(){
        console.log("Subscribed to topic");
    }, function(error){
        console.error("Error subscribing to topic: " + error);
    });

Workarround for me

change FirbasePlugin.java #2300

private void handleTaskOutcome(@NonNull Task<Void> task, CallbackContext callbackContext) {
        try {
            if (task.isSuccessful()) {
                callbackContext.success();
            }else if(task.getException() != null){
                callbackContext.error(task.getException().getMessage());
            }else{
                callbackContext.error("Task failed for unknown reason");
            }
        } catch (Exception e) {
            handleExceptionWithContext(e, callbackContext);
        }
    }

to

private void handleTaskOutcome(@NonNull Task<Void> task, CallbackContext callbackContext) {
        try {
            if (task.isSuccessful() **|| task.getException() == null**) {
                callbackContext.success();
            }else if(task.getException() != null){
                callbackContext.error(task.getException().getMessage());
            }else{
                callbackContext.error("Task failed for unknown reason");
            }
        } catch (Exception e) {
            handleExceptionWithContext(e, callbackContext);
        }
    }

i have no idea why isSuccessful() is false and task.getException() is null, but it works

@ratikanta131
Copy link

I am facing the same error.

@dpa99c dpa99c added android Relates to Android platform bug Something isn't working properly runtime issue An issue related to app runtime labels Aug 11, 2020
@dpa99c dpa99c closed this as completed in 7d7e6d8 Aug 11, 2020
@dpa99c dpa99c added the ready for release Something has been implemented and is awaiting release to npm label Aug 11, 2020
@dpa99c dpa99c removed the ready for release Something has been implemented and is awaiting release to npm label Sep 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
android Relates to Android platform bug Something isn't working properly runtime issue An issue related to app runtime
Projects
None yet
Development

No branches or pull requests

3 participants