Deep linking return null via push notification when i kill the app
See original GitHub issueCurrent Behavior
// App.js
componentDidMount() {
Linking.getInitialURL().then(url => {
this.navigate(url);
});
Linking.addEventListener('url', this.handleOpenURL);
}
handleOpenURL = event => {
this.navigate(event.url);
};
navigate = url => {
const route = url.replace(/.*?:\/\//g, '');
const route_id = route.match(/\/([^\/]+)\/?$/)[1];
const routeName = route.split('/')[0];
this.navigator &&
this.navigator.dispatch(
NavigationActions.navigate({
routeName
params: {
route_id,
},
}),
);
}
i have 2 scenarios in IOS:
- if the app is already opened and it is in the background, send push notification from intercom with deep link, i receive it then i click on it the app opened and redirect me to the screen that i want.
- if i kill the app by swipping it, i send the same notifcation, if i click on it, that only open the app no redirection, in this case if i use safari with my app url schema like
appname://....
, i can open the app and navigate to the disired screen., only from push notification that not work.
Expected Behavior
- if i kill the app and receive notification with deep link action i can navigate to the desired screen.
Your Environment
software | version |
---|---|
iOS | 13.3.1 |
react-navigation | ^4.0.10 |
react-navigation-stack | ^1.10.3 |
react-navigation-tabs | ^2.5.6 |
react-native-reanimated | ^1.4.0 |
react-native-gesture-handler | ^1.5.0 |
react-native-screens | ^2.0.0-alpha.11 |
react-native | 0.61.4" |
node | v13.6.0 |
yarn | 1.21.1 |
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:13
Top Results From Across the Web
React-Native deeplinking if app is closed doesn't work ( React ...
I have a problem regarding Deep Linking. If the app is closed(killed) and it is opened via a deep link it will take...
Read more >Deep link from notification click not calling ... - Airship Support
Step 1 : Kill the application with right swipe. Step 2 : Send push from UA console for "sports" deep link. It will...
Read more >How To Handle Deep Linking in a React Native App
In this tutorial, let's learn how to handle deep linking in a React Native app by creating an example app. We will create...
Read more >Rich push notifications | Customer.io Docs
For now, our rich push feature only supports images and deep links. ... the handler is not set or returns null , the...
Read more >iOS | Localytics Documentation - Upland Software
In order to run the Localytics SDK, you must initialize the SDK using your Localytics app key. You can find your app key...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This issue is caused because when launching the app from a notification the launch options will not contain the initial url, and since the React-Native run time is not available yet, the url event listener won’t fire. A fix for this would involve somehow having the event listener work even when the run time hasn’t loaded yet. Otherwise you will need to parse the options in iOS native code for the launch URL and set the launch option key that react native is looking for.
my solution: node_modules/react-native/Libraries/LinkingIOS/RCTLinkingManager.m
getInitialURL:
RCT_EXPORT_METHOD(getInitialURL:(RCTPromiseResolveBlock)resolve reject:(__unused RCTPromiseRejectBlock)reject) { NSURL *initialURL = nil;
if (self.bridge.launchOptions[UIApplicationLaunchOptionsURLKey]) { initialURL = self.bridge.launchOptions[UIApplicationLaunchOptionsURLKey];
}else if (self.bridge.launchOptions[UIApplicationLaunchOptionsRemoteNotificationKey]){ // keep in mind I’m extracting a dict here as my notification payload is a dictionary but it could be modified to extract any specific thing your payload sends NSDictionary *dict = self.bridge.launchOptions[UIApplicationLaunchOptionsRemoteNotificationKey]; NSString *string_url = [dict valueForKey:@“url”]; initialURL = [NSURL URLWithString:string_url]; } else { NSDictionary *userActivityDictionary = self.bridge.launchOptions[UIApplicationLaunchOptionsUserActivityDictionaryKey]; if ([userActivityDictionary[UIApplicationLaunchOptionsUserActivityTypeKey] isEqual:NSUserActivityTypeBrowsingWeb]) { initialURL = ((NSUserActivity *)userActivityDictionary[@“UIApplicationLaunchOptionsUserActivityKey”]).webpageURL; } } resolve(RCTNullIfNil(initialURL.absoluteString)); }
[“url”]: The url should be determined according to the key of the deeplink of the notification payload.
good luck!