Firebase Refresh Token

后端 未结 3 1859
孤独总比滥情好
孤独总比滥情好 2021-01-18 21:07

Using the method

[FIRInstanceID tokenWithAuthorizedEntity:scope:options:handler]

Im not quite sure what the parameters are calling for? What is

3条回答
  •  余生分开走
    2021-01-18 21:56

    Version for Swift (based on @HeadOnn's answer):

    func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data)
    {
        Messaging.messaging().setAPNSToken(deviceToken, type: .prod) // may be excess
    
        guard let plistPath = Bundle.main.path(forResource: "GoogleService-Info", ofType: "plist"),
            let options = FirebaseOptions(contentsOfFile: plistPath)
        else { return }
    
        InstanceID.instanceID().token(withAuthorizedEntity: options.gcmSenderID, 
                scope: InstanceIDScopeFirebaseMessaging,
                options: ["apns_token": deviceToken])
        { (token, error) in
            // handle token and error
        }
    }
    

提交回复
热议问题