hansemannn / titanium-firebase-analytics

Use the Firebase Analytics SDK in Axway Titanium 🚀
Other
35 stars 18 forks source link

How can we obtain the appInstanceID on android? #72

Open jonesdhtx opened 1 year ago

jonesdhtx commented 1 year ago

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 commented 1 year ago

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

FirebaseAnalytics.addEventListener("appInstanceID", function(e){
  console.log(e.appInstanceID);
});
FirebaseAnalytics.appInstanceID();
jonesdhtx commented 1 year ago

Awesome - that worked!! Thank you :-)

cr0ybot commented 1 year ago

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 commented 1 year ago

it is still an open PR https://github.com/hansemannn/titanium-firebase-analytics/pull/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 commented 1 year ago

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 commented 1 year ago

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.