Initialization problem on Android with version > 2.3.6
See original GitHub issueI have an Xamarin Forms app with version 2.3.6 of the plugin and try to update to a more recent version.
On iOS, no problems but on Android, I tried many versions and I always get this error during FirebasePushNotificationManager.Initialize(this, true, createDefaultNotificationChannel:false)
Default FirebaseApp is not initialized in this process … Make sure to call FirebaseApp.initializeApp(Context) first
My google-services.json file and package names are OK.
Here is my MainApplication init code, CreateNotificationChannels() create notifications channels if required.
Is there something in newer version that may require some code change ?
public override void OnCreate() {
base.OnCreate();
if (Build.VERSION.SdkInt >= Android.OS.BuildVersionCodes.O) {
CreateNotificationChannels();
}
CrossFirebasePushNotification.Current.OnNotificationError += (object source, FirebasePushNotificationErrorEventArgs e) => {
Console.WriteLine("OnNotificationError " + e.Message);
};
EchoMessager.Sync.Server.GetInstance().SetNotificationToken(CrossFirebasePushNotification.Current.Token);
CrossFirebasePushNotification.Current.OnTokenRefresh += (s, p) => {
EchoMessager.Sync.Server.GetInstance().SetNotificationToken(p.Token);
Server.GetInstance().RegisterDevice();
};
CrossFirebasePushNotification.Current.OnNotificationReceived += (s, p) => {
EchoMessager.Sync.Server.GetInstance().ProcessNotification(p.Data);
};
#if DEBUG
FirebasePushNotificationManager.Initialize(this, true, createDefaultNotificationChannel:false);
#else
FirebasePushNotificationManager.Initialize(this,false, createDefaultNotificationChannel:false);
#endif
}
Bug Information
Version Number of Plugin: >2.3.6 Device Tested On: Simulator Tested On: multiple (API level Version of VS: Mac 8.4.2
Issue Analytics
- State:
- Created 4 years ago
- Reactions:4
- Comments:7
Top GitHub Comments
I have add Xamarin.Firebase.Common package directly to Android project and it’s work now. Don’t forget to clean Anndoid project (manually delete bin and obj folders) and rebuild.
Thanks for the solution bro!!!