Firebase 刷新令牌 [英] Firebase Refresh Token

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

问题描述

使用方法

[FIRInstanceID tokenWithAuthorizedEntity:scope:options:handler]

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

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 - 基本上它要求提供 google 项目 ID.它是数字的,如果您之前已经在项目中集成了 GCM,它将是 GCM_SENDER_ID(类似于568520103762").检查您的 Google-info.plist 以找到它.
  2. 范围 - kFIRInstanceIDScopeFirebaseMessaging
  3. OPTIONS - @{@"apns_token": deviceToken}(您将在 didRegisterForRemoteNotifications 方法中获取 DeviceToken)
  4. HANDLER - 如果您收到令牌,则捕获令牌或在此处捕获错误.如果token为nil,则在tokenRefreshNotification"方法中等待token,如果[FIRInstanceID tokenWithAuthorizedEntity:scope:options:handler]中token为nil则自动调用该方法

例子:

 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天全站免登陆