An iOS app has to use two firebase projects. I was super confused when I realized that the order of configuring the FirebaseApp seems to affect the messaging instance obtained by Messaging.messaging().
When I initialize the secondary app first, the Messaging delegate seems only to register registration token changes in the main app at func messaging(_ messaging: Messaging, didRefreshRegistrationToken fcmToken: String)
FirebaseApp.configure(name: AppDelegate.firebase_main_app_name, options: login_app_options)
FirebaseApp.configure()
Messaging.messaging().delegate = SOME DELEGATE OBJECT
But when I register the main app first, the messaging delegate seems to respond to only registration token changes in the secondary app.
When I register the main app first and
retrieve the FCM token by calling messaging_instance.retrieveFCMToken(forSenderID: AppDelegate.gcm_sender_id)
The token retrieved is different from the one from Messaging.messaging().fcmToken
But if I register the secondary app first then the two FCM tokens are the same.
The main firebase app can only send notification if I register the secondary app first.
I'm super confused by all this as this behavior isn't documented anywhere. What if I want to receive notifications from both firebase projects? Is there a way to tell which firebase project Messaing.messaging.delegate would reply to? Also, why does the order of configuring the two Firebase apps make a difference?