I recently implemented push notifications into my React Native app using node-apn
and fcm-node
. This is working fine, and the next step was to implement deep linking.
At the moment, there are two different screens we want to deep link to, and I have already got this working to some extent, both on Android and iOS. Clicking a link on either device in the form of myappscheme://messages/1
for example, opens the app on the relevant screen, whether the app is closed down entirely or in the background.
I did the necessary changes on my node backend to attach a link to the push notifications, and Android is working as expected. For iOS, I have only been partially successful, where the tapping the push notification opens the app and takes me to the correct screen, only if the app is in the background, and not entirely shut down.
I did this by using
useEffect(() => {
const linkingEvent = Linking.addEventListener('url', handleDeepLink);
linkingEvent.remove();
});
I read that this will not work from a cold start, and to use
Linking.getInitialURL().then(function (url) {
alert('getInitialURL')
if (url) {
alert(url)
handleDeepLink(url)
}
}
But, I also have read that without certain configurations, iOS does not store the url in the location where getInitialUrl
searches, and thus changes are required in other places.
I have followed many different sources instructions, some suggesting changes to the Info.plist
, and all suggesting changes to the AppDelegate.mm
.
So far, I have had no success with this. I have very minimal experience with C++ and Swift.
I am using React Native 0.70.8, and Xcode 14.2 (I had issues building my IPA with 14.3 so downgraded back to 14.2).
Anyway, when I launch my app via a push notification when the app is closed entirely, I do not get a url.
I Appreciate any suggestions.