flutterfire
flutterfire copied to clipboard
🚀 [firebase_messaging] allow to switch firebase project at runtime.
What feature would you like to see?
Expose the instaceFor method for public to allow user to switch firebase project at runtime.
I'm not sure what is the reason that why Messaging does not support multiple Firebase Apps. while FirebaseMessagingPlatform alreadly expose this?
i just found the related issue https://github.com/firebase/flutterfire/issues/12428 seem like it about platfrom constraint? but i have seen some native implementation to achieve this by initialize multi FirebaseApp at launch and then choose firebaseApp by name later.
Android
val firebaseMessaging = FirebaseApp.getInstance("appName") .get(FirebaseMessaging::class.java) as FirebaseMessaging firebaseMessaging.token.addOnFailureListener { result.error(it.toString(), it.message, "") }.addOnCompleteListener { println("FCM Token -> ${it.result}") result.success(it.result) }
and this for iOS
let fbsenderID = FirebaseApp.app(name: "appName")?.options.gcmSenderID ?? "" Messaging.messaging().retrieveFCMToken(forSenderID: fbsenderID, completion: { fcmToken, error in tokenReturn(fcmToken, error) })