Firebase刷新令牌
使用该方法
[FIRInstanceID tokenWithAuthorizedEntity:scope:options:handler]
我不太清楚什么参数要求? 什么是授权实体和行动? 我也传递苹果APNS令牌的方法?
- AUTHORIZED_ENTITY – 基本上它要求谷歌项目ID。 它是数字,如果您之前已经将GCM集成到您的项目中,那么它将是GCM_SENDER_ID(类似于“568520103762”)。 检查你的Google-info.plist来find它。
- 范围 – kFIRInstanceIDScopeFirebaseMessaging
- 选项 – @ {@“apns_token”:deviceToken}(您将在didRegisterForRemoteNotifications方法中获得DeviceToken)
- HANDLER – 如果您收到了令牌或者在这里发现错误,请接收令牌。 如果令牌为零,则在“tokenRefreshNotification”方法中等待令牌,如果令牌在[FIRInstanceID tokenWithAuthorizedEntity:scope:options:handler]中为零,
例:
if (![[FIRInstanceID instanceID] token]) { [[FIRInstanceID instanceID] tokenWithAuthorizedEntity:_gcmSenderId scope:kFIRInstanceIDScopeFirebaseMessaging options:_registrationOptions handler:^(NSString * _Nullable token, NSError * _Nullable error) { // Fetch the token or error }]; }
你可以这样做。
[[FIRInstanceID instanceID] setAPNSToken:deviceToken type:FIRInstanceIDAPNSTokenTypeProd]; [[FIRInstanceID instanceID] tokenWithAuthorizedEntity:gcmSenderID scope:kFIRInstanceIDTokenRefreshNotification options:nil handler:^(NSString * _Nullable token, NSError * _Nullable error) { NSLog(@"GCM Registration token = %@",token); NSLog(@"GCM Registration error = %@",error); }];