Generally speaking in our project we added a wrapper class for Firebase Messaging
It nearly contains only
final class MessagingWrapper {
private let messaging: Messaging
init() {
messaging = Messaging.messaging()
}
func configure() {
messaging.delegate = self
}
}
extension MessagingWrapper: MessagingDelegate {
func messaging(_ messaging: Messaging, didReceiveRegistrationToken fcmToken: String?) {
// handle received fcmToken...
}
}
The thing that concerns me is that class configured in this way (i checked a few times that we configure firebase dependencies in correct order, we set APNS token and so on) doesn’t really invoke the delegate func at all.
but if we change configure func to:
func configure() {
Messaging.messaging().delegate = self
}
everything starts to work fine…
Does anyone have any idea what happens in firebase libs that this wrapper breaks whole solution? Do we really need to always invoke Messaging.messaging()
if we want to work with messaging?
I tried looking into documentation but couldn’t really find anything (but i might be as well totally blind). I know I can fix this by always using Messaging.messaging()
, but I just want to understand WHY i can’t hold reference in our wrapper.
RSwob is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.