You don't have the possibility to get Firebase id from using AppCenter.
You have two ways out of this:
1. Skip using AppCenter for pushes in your app. You'd have to implement interaction with Firebase on each platform you support according to documentation. I can share more tips if you choose this option.
2. Convince backend team to use AppCenter API to send individual push notifications https://openapi.appcenter.ms/#/push/Push_Send
I know each of these solutions contradicts one of your requirements. But you'd have to choose only one push service, either AppCenter or Firebase, for your project and stick with it. Personally I vote for Firebase, learned it the hard way.
UPDATED
Most of the time, Firebase documentation is your best friend when switching to FCM.
On the app side:
Setting up Firebase client for iOS and for Android.
Some tricks from my experience:
Android:
You'll have to listen to Firebase InstanceID changes in a descendant of FirebaseMessagingService
and store it for later use. It's not available whenever you need it as it is with AppCenter.
My activity has LaunchMode = LaunchMode.SingleTop
and I override two methods to handle push depending on app state when it arrived: void OnNewIntent(Intent intent)
and void OnPostCreate(Bundle savedInstanceState)
. It might not be your case because I handle silent pushes as well. To check if intent contains a push from Firebase run intent?.GetStringExtra("google.message_id") != null
.
iOS:
Push notifications won't work on iOS simulators and initialization steps might crash your app when run on Simulator. I have created __IOS_SIMULATOR__
constant next to __IOS__
and DEBUG
under Debug|iPhoneSimulator
configuration in csproj file. And used it in AppDelegate.cs like this:
#if !__IOS_SIMULATOR__
new FirebaseCloudMessagingInitializer().Init();
#endif
AppDelegate
offers two methods to override void ReceivedRemoteNotification(UIApplication application, NSDictionary userInfo)
and void DidReceiveRemoteNotification(UIApplication application, NSDictionary userInfo, Action<UIBackgroundFetchResult> completionHandler)
. I used the first one at the beginning and faced edge cases when it was not called. So I had to switch to overriding the latter one. But don't follow this advice blindly, check what suits best for your needs.
Also, beware of https://github.com/firebase/firebase-ios-sdk/issues/2438, I'm not sure whether it was already fixed since I had to deal with it.
In case it is still there, apply the fix from https://github.com/firebase/firebase-ios-sdk/issues/2438#issuecomment-469472087
On backend side:
https://fcm.googleapis.com/fcm/send is so called legacy protocol, use HTTP v1 instead
POST https://fcm.googleapis.com/v1/projects/project_name/messages:send. Explore documentation.
How to authorize send request
How to compose push content