Skip to content

Commit

Permalink
Note about react native firebase sdk capitalization issue (#177)
Browse files Browse the repository at this point in the history
  • Loading branch information
dan-peluso authored Sep 26, 2024
1 parent 61d6449 commit 6cc4ae4
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions Troubleshooting.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,26 +54,26 @@ there are two possible reasons for this:
### Deep links in push notifications not getting sent over to React Native layer when the iOS app is terminated
When the iOS app is terminated (killed from the app switcher by swiping up), there is a bug in React Native that
prevents the native layer from calling the listeners set up in React Native to listen to incoming deep links.
The listener in question here is `Linking.getInitialURL()` which is expected to be called when a deep link is
When the iOS app is terminated (killed from the app switcher by swiping up), there is a bug in React Native that
prevents the native layer from calling the listeners set up in React Native to listen to incoming deep links.
The listener in question here is `Linking.getInitialURL()` which is expected to be called when a deep link is
available while the app is terminated.
You can find the open issue describing this problem on React Native's GitHub repository [Here](https://github.com/facebook/react-native/issues/32350).
There are many workarounds suggested in this issue's thread and a few other similar issues.
However, the workaround that worked for us involves intercepting the launch arguments in the app delegate and adding
You can find the open issue describing this problem on React Native's GitHub repository [Here](https://github.com/facebook/react-native/issues/32350).
There are many workarounds suggested in this issue's thread and a few other similar issues.
However, the workaround that worked for us involves intercepting the launch arguments in the app delegate and adding
a key `UIApplicationLaunchOptionsURLKey`, which React Native expects to be present when calling the `Linking.getInitialURL()` listener.
Here's a method to implement this workaround:


```swift
```swift
- (NSMutableDictionary *)getLaunchOptionsWithURL:(NSDictionary * _Nullable)launchOptions {
NSMutableDictionary *launchOptionsWithURL = [NSMutableDictionary dictionaryWithDictionary:launchOptions];
if (launchOptions[UIApplicationLaunchOptionsRemoteNotificationKey]) {
NSDictionary *remoteNotification = launchOptions[UIApplicationLaunchOptionsRemoteNotificationKey];
if (remoteNotification[@"url"]) {
NSString *initialURL = remoteNotification[@"url"];
if (!launchOptions[UIApplicationLaunchOptionsURLKey]) {
Expand All @@ -85,7 +85,7 @@ Here's a method to implement this workaround:
}
```

Ensure that this method is called from `application:didFinishLaunchingWithOptions:` before calling the superclass method with the
Ensure that this method is called from `application:didFinishLaunchingWithOptions:` before calling the superclass method with the
modified launch arguments, like so:


Expand All @@ -96,14 +96,19 @@ modified launch arguments, like so:
self.initialProps = @{};
// some more code ...
NSMutableDictionary * launchOptionsWithURL = [self getLaunchOptionsWithURL:launchOptions];
return [super application:application didFinishLaunchingWithOptions:launchOptionsWithURL];
}
```

This implementation is included in the example app in this repo and can be used for testing.
This implementation is included in the example app in this repo and can be used for testing.
Make sure to use the URL scheme (rntest://) of the example app when testing.

### iOS APNS Token Troubleshooting
There is an open issue with [`@react-native-firebase/messaging`](https://github.com/invertase/react-native-firebase/issues/8022) where the SDK will uppercase any APNS token returned using `messaging().getAPNSToken()`.
You can verify this by adding a log the `AppDelegate.m` file that prints the deviceToken (you will need to convert to a hex string).
This might have no impact on your use case, but is something to consider when designing.

0 comments on commit 6cc4ae4

Please sign in to comment.