I am developing a Xamarin.Forms application with Xamarin.Android and Xamarin.iOS clients. For push notifications, I am using FirebasePushNotificationPlugin library. It works perfectly on Android, but not on iOS.
On iOS the app simply closes down after the request to use push notifications. So: the "Allow/Don't allow" popup is shown, and when the user clicks on Allow, the app closes down. No exception is thrown or anything.
I have done every step in the setup instructions, but just to double-check, I will show you screenshots of everything:
- Firebase console: I have registered my iOS app on the Firebase console and inputted all required fields (App ID, Bundle ID, App Store ID, App ID Prefix). I have also uploaded the APNs Authentication Key (but no certificates).
- NuGet: I have added Plugin.FirebasePushNotification package to both Xamarin.Forms and Xamarin.iOS projects.
- GoogleService-Info.plist: I have added GoogleService-Info.plist (that I got from the Firebase console) to the Xamarin.iOS project and set its Build Action to
BundleResource
.
- Info.plist: I have enabled remote notification background mode and added FirebaseAppDelegateProxyEnabled (and set it to No) in Info.plist.
- Entitlements.plist: I have added production aps-environment entitlement.
It is production
(and not development
) because I cannot run and debug the app, so the app is actually being uploaded every time to the App Store Connect and tested with TestFlight as an internal tester.
- Xamarin.iOS AppDelegate: I initialize the package in
AppDelegate.FinishedLaunching
method, right afterLoadApplication(new App());
. Thefalse
parameter means that it will not auto register for notifications (it will be registered later manually).
I also override methods RegisteredForRemoteNotifications
, FailedToRegisterForRemoteNotifications
, DidReceiveRemoteNotification
and call respected methods (as stated in the Getting Started instructions).
- Xamarin.Forms: Now this is when all goes to hell on iOS. When it calls
CrossFirebasePushNotification.Current.RegisterForPushNotifications();
, it shows the "Allow/Don't allow" popup, and after the user clicks "Allow", the app simply closes. No exception is thrown or anything (well, at least nothing gets caught in the try/catch statement). The app simply shuts down.
The interesting thing maybe is, that the FCM token is already (successfuly) created before all this and if I send a push message to that token (of that iOS app), the Firebase server returns success
. So I'm guessing that the Firebase part is correct, but there is something wrong with the iOS and/or the library?
Any advice whatsoever will be greatly appreciated!