IOS: Firebase token returning null

I'm currently trying to implement Firebase Cloud Messaging by following the official Firebase docs.

I installed certificates and provisioning profiles with Push Notifications enabled. I also installed all the necessary frameworks (FirebaseMessaging, Firebase) using CocoaPods, and they seem to work fine.

As an application delegate, I tried to initialize a Cloudbase Firebase token with the code below.

let token = FIRInstanceID.instanceID().token()!

I also included GCM, and GoogleService-Info.plist has a GCM sender id value.

The error I am getting is as follows:

2016-11-29 16: 11: 12.358 Firebasesample [3852: 122151] Firebase automatic on-screen reporting is enabled. Call + [FIRAnalytics setScreenName: setScreenClass:] to set the screen name or override the default screen class name. To disable automatic reporting on the screen, set the FirebaseAutomaticScreenReportingEnabled flag to NO in Info.plist

2016-11-29 16: 11: 12.419: Firebase incorrect message settings, nil senderID. fatal error: nil unexpectedly found while deploying optional value

Thank you in advance for any advice / help.

+3
source share
2 answers

There was no answer in the answer:

, https://firebase.google.com/docs/cloud-messaging/ios/client.

didFinishLaunchingWithOptions ( FIRApp.configure()).

NotificationCenter.default.addObserver(self, selector: #selector(tokenRefreshNotification(_:)), name: NSNotification.Name.firInstanceIDTokenRefresh, object: nil)

, :

func tokenRefreshNotification(_ notification: Notification) {

    guard let token = FIRInstanceID.instanceID().token() else {
        QL3("No firebase token, aborting registering device")
        return nil
    }

    //register your token somewhere..
    registerToken(token)
}
+3

Source: https://habr.com/ru/post/1675317/


All Articles