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

How can we obtain the appInstanceID on android? #72

Open
jonesdhtx opened this issue Oct 8, 2022 · 6 comments
Open

How can we obtain the appInstanceID on android? #72

jonesdhtx opened this issue Oct 8, 2022 · 6 comments

Comments

@jonesdhtx
Copy link

I need to get the appInstanceID on android (like we can for iOS - doc link). Is this possible?

Having this value will allow us to send analytics events to GA4 using Measurement Protocol from our server-side component.
More info on this approach: https://firebase.google.com/codelabs/firebase_mp#1

@m1ga
Copy link
Collaborator

m1ga commented Oct 10, 2022

Please try:
firebase.analytics-android-5.2.0.zip

FirebaseAnalytics.addEventListener("appInstanceID", function(e){
  console.log(e.appInstanceID);
});
FirebaseAnalytics.appInstanceID();

@jonesdhtx
Copy link
Author

Awesome - that worked!! Thank you :-)

@cr0ybot
Copy link

cr0ybot commented Aug 21, 2023

I downloaded the 5.2.0 package (why isn't it available in the releases?) but the event listener mentioned by @m1ga isn't working for me. In fact, I'm getting a warning FA: Failed to retrieve Firebase Instance Id several times at app open and then any time I attempt to track a screen view or event. This is in an app that was working previously that I need to update to keep it active on the Play store, so no other changes have been made.

@m1ga
Copy link
Collaborator

m1ga commented Aug 21, 2023

it is still an open PR #75

Since you post it in this thread: are you using appInstanceID? Or is this a general issue (there weren't any other code changes).

@cr0ybot
Copy link

cr0ybot commented Aug 21, 2023

I posted here because I keep getting the warning, and this issue seemed relevant, but maybe it isn't. I wouldn't have posted at all except I was confused about the android 5.2.0 package, since I found it here while looking into the warning, hoping that a module upgrade might fix the warning. I'm not specifically using the appInstanceID for anything, so I assume as long as I still get analytics it's fine.

@m1ga
Copy link
Collaborator

m1ga commented Aug 22, 2023

I see. The warnings shouldn't been there (I'm not seeing them in my test project) but perhaps it's better in an own issue.
If you still get the data it should be fine. Setup should just be the google-services.json file in your platform/android folder and then use the code from the module.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants