question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

FirebaseAnalytics.getAppInstanceId() for android devices does not work

See original GitHub issue

Describe the bug When using your own example, calling FirebaseAnalytics.getAppInstanceId(): Its returning an string like: ‘com.google.android.gms.tasks.zzu@575g1e6

After checking FirebaseAnalytics class at android folder, I’ve found the problem:

public void getAppInstanceId(PluginCall call) {
    try {
      if (mFirebaseAnalytics == null) {
        call.error(MISSING_REF_MSSG);
        return;
      }
      String instanceId = mFirebaseAnalytics.getAppInstanceId().toString();  // this line isn't returning the expected value

If you read the documentation of FirebaseAnalytics, you will see that getAppInstanceId will return an Task<String> (what explain the answer I am receiving)

How to solve it Replace your method for something like:

     @PluginMethod
     public void getAppInstanceId(final PluginCall call) {
           try {
                  if (mFirebaseAnalytics == null) {
                       call.error(MISSING_REF_MSSG);
                       return;
           }
      Task<String> task = this.mFirebaseAnalytics.getAppInstanceId();
      task.addOnSuccessListener(new OnSuccessListener<String>() {
        @Override
        public void onSuccess(String string) {
          JSObject result = new JSObject();
          result.put("instanceId", string);
          call.success(result);
        }
      });
      
    //task.addOnFailureListener(...)
    } catch (Exception ex) {
      call.error(ex.getLocalizedMessage());
    }
  }

Its just required to implement the addOnFailureListener to finish it.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
Franjoocommented, Jun 3, 2021

Sorry for the late reply. Version 0.3.2 works perfectly! Thanks for resolving this issue 👍

1reaction
brownoxfordcommented, May 19, 2021

Is there any news about resolving this issue? It’s a bit frustrating since this seems to need only a small correction.

Thanks for bringing this up again @Franjoo , I’ll see if I can get on it this week.

Read more comments on GitHub >

github_iconTop Results From Across the Web

FirebaseAnalytics - Google
Clears all analytics data for this app from the device and resets the app ... If your app does not use a distinct...
Read more >
Build fails in getAppInstanceId() · Issue #97
Hey, I have same issue with my app. I tried to add @capacitor-community/firebase-analytics@1.0.1-alpha.0 but it does not work. I can notice ...
Read more >
FirebaseAnalytics | Google Play services
Clears all analytics data for this app from the device and resets the app ... Passing null indicates that the event has no...
Read more >
Get user_pseudo_id from firebase client sdk?
... that I can find in the BigQuery user_pseudo_id column. Example for android: FirebaseAnalytics.getInstance(this).getAppInstanceId().
Read more >
capacitor-community/firebase-analytics
Capacitor community plugin for native Firebase Analytics. ... You may need to run File > Sync Project with Gradle Files in order for...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found