Firebase Refresh Token

后端 未结 3 1854
孤独总比滥情好
孤独总比滥情好 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:57

    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]

    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
        }];
    
    }
    

提交回复
热议问题