I am initializing Firebase dynamically with FirebaseApp.initializeApp(Builder) with all the project attributes set(including gcmSenderId), so I have no google services JSON in the project root as I'm choosing the firebase project at login. Everything works fine(auth sdk, firestore sdk, storage sdk etc.) apart from FCM. I'm getting the token successfully through onNewToken() method and then trying to send a test push to the token. I'm not getting the test push.
I've tried to set "firebase_messaging_auto_init_enabled" and "firebase_analytics_collection_enabled" to false and then after initializeApp to call FirebaseMessaging.getInstance().setAutoInitEnabled(true); but still doesn't work.
I can see in the logs that "Missing google_app_id. Firebase Analytics disabled. See ..." error is thrown so this may be the reason it's not working, but can't figure out why as google services json is missing intentionally and everything is fine after dynamically setting up Firebase.
Related
I only use Firebase for Crashlytics. The Android app needs to read the Firebase Key from a property that is not available at build time, so instead of using the default json configuration file it uses the following code which is executed during Application's onCreate() :
val builder = FirebaseOptions.Builder()
.setProjectId(firebaseProjectId)
.setApplicationId(applicationId)
.setApiKey(firebaseKey)
FirebaseApp.initializeApp(context, builder.build())
This change was made some months ago and I've noticed that the firebase analytics stopped worked since the change was published. I do receive crash reports from crashlytics but all of the other data that is grabbed automatically is not there anymore: active users, unique users, analytics events, etc.
So Crashlytics is giving very bad data because it can only take as unique users the ones that still have older versions of the app.
Am I missing additional setups for Firebase Analytics to work under these scheme?
It sounds like you might have gotten rid of the google-services.json file that you would use to integrate with Firebase. Your Firebase Analytics integration won't work without that file. You can download it again from your Firebase project and add it to the app project again.
I canĀ“t figure it out anymore, I've tested all kind of things, im testing to receive the token from firebase messaging. Im almost secure that first time i've received it but after that, no more and always the same error. this is being tested with android 11 wear os 3. so it is an emulator to a weareable.
The most common ways to solve this by comments is adding options to initialization or adding Firebase Installations api to the credentials of the api key, or checking the networkconfiguration xml with some options but nothing. nothing works.
I've testing with the last firebase bom(30.3.1), and tried with lower versions too.
at the begginings of the logs says "I/FirebaseInitProvider: FirebaseApp initialization successful" but then all errors after a while.
I have an Android app which uses Firebase Auth, and while fixing some issues I had, I noticed that there is no need to add the file google-services.json to the project.
My issue was the following. I perform a sign-in via Google Sign-In, and in the GSO (Google Sign-In Options) I specify
gsob.requestIdToken(".....apps.googleusercontent.com");
gsob.requestEmail();
because I want an idToken which I then can pass to the Firebase SDK in order to sign the user into Firebase (I'm using it this way for historical reasons).
It had stopped working which was the reason why I was meddling around with the google-services.json file, since I had deleted a Client-ID in console.developers.google.com and thought I made a mistake.
While being at removing stuff, I also removed an entry
<meta-data android:name="identitytoolkit.server_client_id" android:value="....apps.googleusercontent.com" />
and some more identitytoolkit metadata entries from the Manifest.
In the end the only thing that would matter was that the correct client-id is passed to gsob.requestIdToken(".....apps.googleusercontent.com");
I'm not sure if Google had some hiccups with the idTokens between Google Sing-In and Firebase during these last two days, but in the end I think I really didn't change anything to make it work again.
So the last couple of minutes I was reading through the Firebase documentation, and read that there are now two options for adding Firebase to an Android app, one is the one I used before, and then there's a new option to use the Firebase Assistant.
I never used the Firebase Assistant, but am wondering if it has been enabled automatically in my app (I never clicked "Click Connect to Firebase to register your app with an existing or new Firebase project and to automatically add the necessary files and code to your Android project.")
How can I find out if something in Android Studio has been altered to add my Firebase configuration automatically? Where do I know which client-id's it's using?
I'm asking because even the email-based authentication with Firebase (which is not using Google Sign-In explicitly) is working in the app, and there are is no json file or other client-id's in the Manifest or in the code which could be used for this.
Nothing has changed in the setup instructions. You either need to have the Play services plugin and google-server.json present, or you need to duplicate its work manually. The only ways to manually duplicate its work are to add the specific string resources to your app that it requires, or call initalizeApp with your specific settings. There are currently no alternatives.
I have a xamarin android app and I want to add notifications. I followed the instructions from this link:
https://developer.xamarin.com/guides/android/application_fundamentals/notifications/remote-notifications-with-fcm/
Everything worked great until I got to the Implement Client App Code section. At first, when I clicked the button to get the InstanceId token, I didn't get anything. So I added the bit of code that shows the google_app_id. Mine does not match the mobilesdk_app_id value in the json file. But then I did get an InstanceId in the output. I used that id in the firebase console and the message fails, "Unregistered registration token". I followed the directions exactly, twice. And searched for the error but did not find any answers. I guess my token is wrong? How do I fix that?
I just went through the same tutorial and received the same error in the firebase console. My problem turned out to be my android emulator configuration.
In the Android Virtual Device Manager I had to set my device's Target to Google APIs
I also had to install Google Play services from the Android SDK Manager
Lastly, I uninstalled my app on the emulator and reinstalled it to refresh the token.
After these steps i was able to send push notifications from the firebase console.
This video helped me out.
I am getting an error when I try to send messages via the Firebase Notification screen in the console. It says I have an invalid token format, but I have used previously used tokens collected with the same method successfully.
I was not getting this error a few days ago, and notifications were working properly. I just pushed an update to the Google Play Store recently, but this update did not touch any code relating to the notifications.
status.firebase.google.com says that notifications are currently up. All other Firebase usages in my app (database, storage, auth) are working properly.
When I updated my app, I did not change my google-services.json file at all. Do I need to do some sort of update to this file, or some sort of version change on the Firebase Console to keep the versions consistent between the APK and the console?
As mentioned by #Arthur Thomson (in the comments), your registration token may change as a result of an update in the application. It does matter that you did not change the google-services.json if the user reinstalled or updated the application the token maybe changed.
According to the docummentation about the device registration token, the registration toke may change when:
The app deletes Instance ID
The app is restored on a new device
The user uninstalls/reinstall the app
The user clears app data.
So you would need to retrieve the new registration token using the onTokenRefresh() method in your Android client application. I mean, you just need to implement a code to retrieve the new token if it changes.
Hope this helps