Skip to content

Commit

Permalink
fix(firebase_messaging): Stream new token via onTokenRefresh when get…
Browse files Browse the repository at this point in the history
…Token invoked for iOS. (#8166)
  • Loading branch information
russellwheatley committed Feb 24, 2022
1 parent f21004e commit 28b396b
Showing 1 changed file with 8 additions and 0 deletions.
Expand Up @@ -599,10 +599,18 @@ - (void)messagingGetNotificationSettings:(id)arguments

- (void)messagingGetToken:(id)arguments withMethodCallResult:(FLTFirebaseMethodCallResult *)result {
FIRMessaging *messaging = [FIRMessaging messaging];

// Keep behaviour consistent with android platform, newly retrieved tokens are streamed via
// onTokenRefresh
bool refreshToken = messaging.FCMToken == nil ? YES : NO;
[messaging tokenWithCompletion:^(NSString *_Nullable token, NSError *_Nullable error) {
if (error != nil) {
result.error(nil, nil, nil, error);
} else {
if (refreshToken) {
[self->_channel invokeMethod:@"Messaging#onTokenRefresh" arguments:token];
}

result.success(@{@"token" : token});
}
}];
Expand Down

0 comments on commit 28b396b

Please sign in to comment.