onNewToken is not called on iOS Side sometimes
Can't reproduce why this happens. But if this occurs as a workaround for now, you can call
val firebasePushToken = NotifierManager.getPushNotifier().getToken() in coroutine scope, and this will trigger onNewToken
I've never received onNewToken on iOS, even after fresh install, but I assume that it could be Firebase configuration problem - like connecting Firebase with APNS certificate
If you tried above workaround solution, maybe you didn't enable Push Notifications in XCode
This happens because of bad understanding of iOS garbage collection.
internal class FirebasePushNotifierImpl : PushNotifier {
init {
MainScope().launch {
println("FirebasePushNotifier is initialized")
UIApplication.sharedApplication.registerForRemoteNotifications()
FIRMessaging.messaging().delegate = FirebaseMessageDelegate()
}
}
..
}
The FIRMessaging.messaging().delegate is a WEAK reference, all iOS sdk delegates are weak reference by design.
So the FirebaseMessageDelegate() instance is garbage collected at any moment after it is set.
I am actually surprised that it works at all.
Just add strong reference to it, aka private val firMessageDelegate = FirebaseMessageDelegate() as a member of the class.
@KoTius Thank you very much for this info, will check it
This should be fixed in 1.2.0-alpha02 version