Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Airship getInitialDeepLink() #625

Open
ibrahimchraibi opened this issue Feb 24, 2025 · 5 comments
Open

Airship getInitialDeepLink() #625

ibrahimchraibi opened this issue Feb 24, 2025 · 5 comments

Comments

@ibrahimchraibi
Copy link

Hello,

Issue:
We are using Airship push notifications alongside React Navigation in our app, but we’re having trouble correctly handling deep links when the app is in the killed state.

React Navigation’s recommended approach for handling deep linking is outlined here:
React Navigation - Deep Linking

We have already set up a listener, and deep links work correctly when the app is in the foreground or background. However, when the app is killed, we encounter the following warning:

The navigation state parsed from the URL contains routes not present in the root navigator.

Our assumption is that the deep link is being processed before the navigation system is fully ready. React Navigation provides a way to override getInitialURL to properly handle this scenario and ensure that navigation occurs only when ready.

However, to use this solution, we need a way to retrieve the initial deep link URL from the Airship SDK.

Proposed Solution
Would it be possible to expose a method like getInitialDeepLink() in the Airship SDK?

I found a related discussion here: Issue #58, but it doesn't seem like this feature was ever implemented.

Considering that React Navigation is the most widely used navigation library for React Native, many developers would likely benefit from having a reliable way to retrieve the initial deep link when the app starts from a killed state.

Questions

  • Is there currently any workaround to fetch the initial deep link URL from the Airship SDK?
  • Would it be possible to add a method to retrieve this value?

Thanks a lot for looking into this! We appreciate your help.

@rlepinski
Copy link
Contributor

The plugin will queue up the deep links if you do not have an active listener. Could you try to move the listener to when your routes are ready?

@ibrahimchraibi
Copy link
Author

ibrahimchraibi commented Feb 25, 2025

Thanks for your answer @rlepinski. I looked again into React Navigation doc, and as far as I can tell the only way to define/handle the deep link listener is when creating the navigator initially, in this case I don't see how we could change it so that it is only being used when routes are ready.

https://reactnavigation.org/docs/deep-linking/#third-party-integrations

I think this is exactly why they provide 2 different methods:

  • getInitialURL method to handle initial app opening
  • subscribe method to listen/handle new upcoming urls

They also explain that in:

Similar to the above example, you can integrate any API that provides a way to get the initial URL and to subscribe to new incoming URLs using the getInitialURL and subscribe options.

Thanks again.

@rlepinski
Copy link
Contributor

getInitialUrl ties us into a weird lifecycle that I am not sure we can support properly. On iOS, the notification response comes in after the app is launched in the user notification callback. We would have to see if that callback happens before the react native context is up otherwise we will have a race condition. It use to be the push payload would be provided in the launch options but that is no longer the case.

Ill have someone take a look in the next day or so to see how we can integrate into that library properly without a getInitialURL method.

@ibrahimchraibi
Copy link
Author

getInitialUrl ties us into a weird lifecycle that I am not sure we can support properly. On iOS, the notification response comes in after the app is launched in the user notification callback. We would have to see if that callback happens before the react native context is up otherwise we will have a race condition. It use to be the push payload would be provided in the launch options but that is no longer the case.

Ill have someone take a look in the next day or so to see how we can integrate into that library properly without a getInitialURL method.

Thanks a lot!

@rlepinski
Copy link
Contributor

Sorry about the delay on this, we are trying to get this plugin compatible with 0.78 then we will get back to this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants