From b2ffe115874c422414d58038d5d01e1b411c5a6c Mon Sep 17 00:00:00 2001 From: Thomas P Date: Thu, 18 Jun 2020 12:30:02 +0200 Subject: [PATCH] fix(ios): handle nil messaging token (#3790) Co-authored-by: Mike Hardy [publish] --- .../ios/RNFBMessaging/RNFBMessaging+FIRMessagingDelegate.m | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/messaging/ios/RNFBMessaging/RNFBMessaging+FIRMessagingDelegate.m b/packages/messaging/ios/RNFBMessaging/RNFBMessaging+FIRMessagingDelegate.m index ab5a49fa97..d6e9aa460e 100644 --- a/packages/messaging/ios/RNFBMessaging/RNFBMessaging+FIRMessagingDelegate.m +++ b/packages/messaging/ios/RNFBMessaging/RNFBMessaging+FIRMessagingDelegate.m @@ -49,6 +49,9 @@ - (void)observe { // JS -> `onTokenRefresh` - (void)messaging:(FIRMessaging *)messaging didReceiveRegistrationToken:(NSString *)fcmToken { + if (fcmToken == nil) { // Don't crash when the token is reset + return; + } [[RNFBRCTEventEmitter shared] sendEventWithName:@"messaging_token_refresh" body:@{ @"token": fcmToken }];