When looking at the disconnect() method and it's description it says the following in the docs
Disconnect the current FIRMessaging data connection. This stops any attempts to connect to FIRMessaging. Calling this on an already disconnected client is a no-op.
But looking at the shouldEstablishDirectChannel property
When set to YES, Firebase Messaging will automatically establish a socket-based, direct channel to the FCM server. You only need to enable this if you are sending upstream messages or receiving non-APNS, data-only messages in foregrounded apps. Default is NO.
It seems that they don't do exactly the same thing, but I might be wrong. Can anyone clarify this for me?
So what i found is this.
the disconnect() and the connect() functions are no longer needed. You can just turn the bolean to true and it makes the connection.
I was bonking my head against the wall because if that error warning.
func applicationDidEnterBackground(_ application: UIApplication) {
Messaging.messaging().disconnect()
print("Disconnected from FCM.")
}
to:
func applicationDidEnterBackground(_ application: UIApplication) {
Messaging.messaging().shouldEstablishDirectChannel = false
print("Disconnected from FCM.")
}
and the same goes for the connect by turning the bolean to true. since there is now where explaining this change i tought i should awnser. I also tested this on a device and i am still reciving push notifications.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With