Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

disconnect() is deprecated: Please use the shouldEstablishDirectChannel property instead

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?

like image 568
Chris Avatar asked May 25 '17 08:05

Chris


1 Answers

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.

like image 142
Cees Avatar answered Nov 19 '22 09:11

Cees