Skip to content

Commit

Permalink
feat(app, ios)!: adopt firebase-ios-sdk 10.4.0
Browse files Browse the repository at this point in the history
BREAKING CHANGE: You must have an APNS token before calling getToken to
get an FCM token on iOS. Previously it was not required. See documentation
for setAPNSToken if you are using getToken in testing or have disabled
FCM Swizzling, and use setAPNSToken to set a token before using getToken
  • Loading branch information
mikehardy committed Feb 1, 2023
1 parent 8d75b36 commit 1b8df4c
Show file tree
Hide file tree
Showing 4 changed files with 124 additions and 118 deletions.
2 changes: 1 addition & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ Open your projects `/ios/Podfile` and add any of the globals shown below to the

```ruby
# Override Firebase SDK Version
$FirebaseSDKVersion = '10.3.0'
$FirebaseSDKVersion = '10.4.0'
```

Once changed, reinstall your projects pods via pod install and rebuild your project with `npx react-native run-ios`.
Expand Down
2 changes: 1 addition & 1 deletion packages/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
},
"sdkVersions": {
"ios": {
"firebase": "10.3.0",
"firebase": "10.4.0",
"iosTarget": "11.0",
"macosTarget": "10.13"
},
Expand Down
10 changes: 8 additions & 2 deletions packages/messaging/ios/RNFBMessaging/RNFBMessagingModule.m
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ - (NSDictionary *)constantsToExport {
: (NSString *)senderId
: (RCTPromiseResolveBlock)resolve
: (RCTPromiseRejectBlock)reject) {
// #if !(TARGET_IPHONE_SIMULATOR)
if ([UIApplication sharedApplication].isRegisteredForRemoteNotifications == NO) {
[RNFBSharedUtils
rejectPromiseWithUserInfo:reject
Expand All @@ -126,7 +125,14 @@ - (NSDictionary *)constantsToExport {
}];
return;
}
// #endif

// As of firebase-ios-sdk 10.4.0, an APNS token is strictly required for getToken to work
NSData *apnsToken = [FIRMessaging messaging].APNSToken;
if (apnsToken == nil) {
DLog(@"RNFBMessaging getToken - no APNS token is available. Firebase requires an APNS token to "
@"vend an FCM token in firebase-ios-sdk 10.4.0 and higher. See documentation on "
@"setAPNSToken and getAPNSToken.")
}

[[FIRMessaging messaging]
retrieveFCMTokenForSenderID:senderId
Expand Down
Loading

1 comment on commit 1b8df4c

@vercel
Copy link

@vercel vercel bot commented on 1b8df4c Feb 1, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.