Firebase刷新令牌 [英] Firebase Refresh Token

查看:188
本文介绍了Firebase刷新令牌的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用方法

[FIRInstanceID tokenWithAuthorizedEntity:scope:options:handler]

我不太确定参数的要求是什么?什么是授权实体和行动?我也将APNS令牌从apple传递给该方法吗?

Im not quite sure what the parameters are calling for? What is the authorized entity and action? Also do I pass in the APNS token from apple to that method?

推荐答案


  1. AUTHORIZED_ENTITY - 基本上它要求谷歌项目ID。它是数字的,如果您之前已经在项目中集成了GCM,那么它将是GCM_SENDER_ID(类似于568520103762)。检查你的Google-info.plist以找到它。

  2. SCOPE - kFIRInstanceIDScopeFirebaseMessaging

  3. 选项 - @ {@apns_token:deviceToken}(你将会在didRegisterForRemoteNotifications方法中获取DeviceToken)

  4. HANDLER - 如果您已收到令牌或在此处捕获错误,请捕获令牌。如果token为nil,则在tokenRefreshNotification方法中等待令牌,如果令牌在[FIRInstanceID tokenWithAuthorizedEntity:scope:options:handler]

  1. AUTHORIZED_ENTITY - Basically it asks for the google project id. It is numeric, and if you already had GCM integrated in your project before, it would be GCM_SENDER_ID (something like "568520103762"). Check your Google-info.plist to find it.
  2. SCOPE - kFIRInstanceIDScopeFirebaseMessaging
  3. OPTIONS - @{@"apns_token": deviceToken} (You will get DeviceToken in didRegisterForRemoteNotifications method)
  4. HANDLER - Catch token if you have received token or catch the error here. If token comes nil, then wait for token in "tokenRefreshNotification" method, which will be called automatically if the token is nil in [FIRInstanceID tokenWithAuthorizedEntity:scope:options:handler]

$ b中为nil,将自动调用该方法
$ b

示例:

Example:

 if (![[FIRInstanceID instanceID] token]) {
    [[FIRInstanceID instanceID] tokenWithAuthorizedEntity:_gcmSenderId scope:kFIRInstanceIDScopeFirebaseMessaging options:_registrationOptions handler:^(NSString * _Nullable token, NSError * _Nullable error) {

        // Fetch the token or error
    }];

}

这篇关于Firebase刷新令牌的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆