简体   繁体   中英

FireBase iOS Messaging, fails to fetch APNS Token

Ok, I have spent half of yesterday and half of this morning searching the boards and Google, and Firebase Docs for the solution. Just to be clear.

I have FirebaseAppDelegateProxyEnabled set to NO in my info.plist, i'll post my appDelegate methods, but I have looked through the docs many times:

didFinishLaunchingWithOptions:

    customizeAppearance()
    FIRApp.configure()

    tracker.appLaunch()

    registerForPushNotifications(application)
    notificationCenter.addObserver(self, selector: #selector(AppDelegate.tokenRefreshNotification), name: kFIRInstanceIDTokenRefreshNotification, object: nil)

    return PersistentStoreManager.sharedInstance.managedObjectContextHasBeenInitialized()

didReceiveRemoteNotification:

    //Full message
    print("%@", userInfo)


    articleID = "\(userInfo["articleId"]!)"
    notificationCenter.postNotificationName("newArticle", object: nil)

registerForPushNotifications:

    let notificationSettings = UIUserNotificationSettings(
        forTypes: [.Badge, .Sound, .Alert], categories: nil)
    application.registerUserNotificationSettings(notificationSettings)
    application.registerForRemoteNotifications()

didRegisterForRemoteNotificationsWithDeviceToken:

//send the APNs token to firebase
    FIRInstanceID.instanceID().setAPNSToken(deviceToken, type: FIRInstanceIDAPNSTokenType.Sandbox)
    print("In did register For remote Not with token: \(FIRInstanceID.instanceID().token())")
}

tokenRefreshNotification:

    let refreshedToken = FIRInstanceID.instanceID().token()!
    //send token information to server
    self.manager.sendNotificationToken(refreshedToken)

    //double check to connect to FCM, may have failed when attempted before having a token
    connectToFcm()

func application(application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: NSError) {
    print("Failed to register:", error.description)
}

Console Log:

WARNING: Firebase Analytics App Delegate Proxy is disabled. To log deep link campaigns manually, call the methods in FIRAnalytics+AppDelegate.h.
Configuring the default app.
<FIRAnalytics/INFO> Firebase Analytics v.3201000 started
<FIRAnalytics/INFO> To enable debug logging set the following application argument: -FIRAnalyticsDebugEnabled
<FIRInstanceID/WARNING> Failed to fetch APNS token Error Domain=com.firebase.iid Code=1001 "The operation couldn’t be completed. (com.firebase.iid error 1001.)"
<FIRMessaging/INFO> FIRMessaging library version 1.1.0
[4459:501] <FIRAnalytics/INFO> Firebase Analytics enabled
 CFNetwork SSLHandshake failed (-9806)
2016-07-28 10:26:08.245: <FIRInstanceID/WARNING> APNS Environment in profile: development
In did register For remote Not with token: Optional("fWmrxcdNICg:APA91bF_pVwLixBXFuRZEF0w64J7zizSQfpaYNjJhf9g95fZxDmqKD-I1gnaxufkmbNvGZZKs8ifL6ZlXY9nWBc0utgVjEBJG7tUNnA8ciOzeyW9wtfSHyq0IYIf4OepJ4qTJf8qLpIR")
In did register For remote Not with token: Optional("fWmrxcdNICg:APA91bF_pVwLixBXFuRZEF0w64J7zizSQfpaYNjJhf9g95fZxDmqKD-I1gnaxufkmbNvGZZKs8ifL6ZlXY9nWBc0utgVjEBJG7tUNnA8ciOzeyW9wtfSHyq0IYIf4OepJ4qTJf8qLpIR")

And I am targeting iOS 8.3 and up. I have both my development and prod push notification certs uploaded into Firebase as well.

I have breakpoints set, my tokenRefreshNotification() doesn't get called and neither does didReceiveRemoteNotification()

I don't know what is going wrong, and I am suppose to send the application to the app store Monday. I was getting notifications fine most of the day yesterday, and then they stopped. I don't get them from the Firebase console or from our web service servers.

OK I found my problem. Incase someone else runs into this problem I wanted to post the solution. Be sure to check your code signing identities and provisioning profiles. I'm not sure how mine changed yesterday, however whenever I fixed these code signing settings my push notifications came in great, I haven't missed one yet.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM