Initialize FirebaseApp for FCM after Permissions granted #559
|
Hi, private static MauiAppBuilder RegisterFirebaseServices(this MauiAppBuilder builder) {
builder.ConfigureLifecycleEvents(events => {
#if ANDROID
events.AddAndroid(android => android.OnCreate((activity, _) =>
CrossFirebase.Initialize(activity, () => Platform.CurrentActivity)));
#elif IOS
events.AddiOS(iOS => iOS.FinishedLaunching((_, __) => {
CrossFirebase.Initialize();
FirebaseCloudMessagingImplementation.Initialize();
return false;
}));
#endif
});
builder.Services.AddSingleton(_ => CrossFirebaseCloudMessaging.Current);
return builder;
}to the app lifecycle. |
Replies: 1 comment 1 reply
|
If your concern is that a permissions dialog will display 'too soon', then I don't think you need to change anything. Simply initializing Firebase at startup doesn't do that. If you have some other reason to not want FCM to automatically initialize, then you can follow the documentation at https://firebase.google.com/docs/cloud-messaging/android/get-started#prevent-auto-initialization |
If your concern is that a permissions dialog will display 'too soon', then I don't think you need to change anything. Simply initializing Firebase at startup doesn't do that.
If you have some other reason to not want FCM to automatically initialize, then you can follow the documentation at https://firebase.google.com/docs/cloud-messaging/android/get-started#prevent-auto-initialization