Add the appropriate “Tag” based on what Expo library you have a question on.
I’m using the Linking package to open a local link within an expo app when a notification is pressed. It works fine on android and older iphones (7,8), but I’m having trouble on ios 14 on an iphone 12 pro. It redirects to the home page when clicked. The user is running the app through Expo Go via a tunnel connection. See the code below, thanks in advance:
Hey @rowellscott, the code snippet refers to variables that aren’t present here. Can you provide a complete, runnable repro case of this so we can confidently test it on our end?
Hey Adam,
I was able to get around the above issue by using the linking prop on the React Navigation Navigation Container with the code below. I’m still trying to figure out the best way to do the linking if the app isn’t running and I hit a notification. It navigates to the home page instead of the linked page. Appreciate any advice you might have on how to do this.
<NavigationContainer
fallback={<Text>Loading...</Text>}
linking={{
prefixes: [prefix],
config: {
screens: {
Login: "login",
Home: "home",
PostingDescription: "postingDescription/:id",
},
},
subscribe(listener) {
const onReceiveURL = ({ url }: { url: string }) => listener(url);
// Listen to incoming links from deep linking
Linking.addEventListener("url", onReceiveURL);
console.log(url)
// Listen to expo push notifications
const subscription = Notifications.addNotificationResponseReceivedListener(response => {
console.log("notification", response)
// response.notification.request.content.data.url
let url = prefix + "postingDescription/" + response.notification.request.content.data.postingID;
console.log("url ", url)
// Any custom logic to see whether the URL needs to be handled
//...
// Let React Navigation handle the URL
listener(url);
});
return () => {
// Clean up the event listeners
Linking.removeEventListener("url", onReceiveURL);
subscription.remove();
};
},
}}
>
<StackNavigator />
</NavigationContainer>