React-native-firebase: dynamicLinks().onLink() not getting called when app is freshly launched from link

Created on 26 Mar 2020  路  22Comments  路  Source: invertase/react-native-firebase

Hello Guys,

I have integrated Firebase dynamic links with @react-native-firebase/dynamic-links version 6.3.4

const handleDynamicLink = async link => {
    console.log('***', link)
}

  useEffect(() => {
    const unsubscribe = dynamicLinks().onLink(handleDynamicLink)
    // When the is component unmounted, remove the listener
    return () => unsubscribe()
  })

The handleDynamicLink is called when the app is already in background.

However if the app is closed and freshly launched by tapping on the link it does not get called.

Please help.

package.json:

"@react-native-firebase/app": "^6.3.4",
"@react-native-firebase/dynamic-links": "^6.3.4",

All 22 comments

I have the same issue on Android (RNF 6.3.4). iOS not tested yet.

Have you tried usage with getInitialLink? The onLink handler will only be called when the app is in the foreground.

Have you tried usage with getInitialLink? The onLink handler will only be called when the app is in the foreground.

@Ehesp Oh my fault, getInitialLink works and returning a link. Sorry, I miss understood the documentation about this method.

@Ehesp

Probably I found another issue connected with this feature. I have below flow in my app:

  1. The user gets an invitation with a dynamic link to the chat room on email
  2. Open the link and goes to the app, then App read the token from a link and processing registration to the chat room.

So when I'm testing this on Android (debug mode) the dynamic link from the first invitation works well, but when you open another invitation, getInitialLink method still returns link with the token from the first link. onLink method doesn't work too because every time I'm clicking on the link the app starts from scratch.

I'm missing something or should I generate not only a new token but the whole link should be different? Or maybe there is the way to clear the initial link?

That seems like a bug with the initial link not getting removed once it's been consumed. Let me take a look, however it's probably worth creating a separate issue so we can track it.

@Ehesp
I found an old bug with a possible solution. I will check that and will return with feedback.

https://github.com/invertase/react-native-firebase/issues/2631

Nope, I've added:

android:launchMode="singleTask"

to AndroidManifest but still, getInitialLink returns link from the first invitation.

Yeah I don't think that would sort it, that's just how Android handles the activity when launching an intent.

Does it work on iOS?

Can I test this feature without the deployed app to the App Store? I have the app only in TestFlight now.

Yeah you can, we test on real devices with it just being installed from XCode.

But when I'm trying open link (slack, email) on ma device (iPhone XS) iOS redirect me to the fallback page (website).
I've added App Store ID, Bundle ID, and Team ID in the firebase console few days ago.

E: Oh, I forgot about this configuration for iOS https://youtu.be/KLBjAg6HvG0?t=407

@Ehesp Ok, I got it, the app is opening after clicking on the link but it is even worse than on Android. getInitiaLink returns always null and onLink doesn't work too. 馃槩

@ahanusek did you found any solution ?

@thilinawarnakula Yes, I will try to share my solution later (today or tomorrow).

@ahanusek Could you share your solution for iOS? I am having the same issue.

@markuscosinus there are two separate methods to handle this.
1.App in Foreground events
2.App in Background/Quit events

same issue happens for me. Backround/quit method works. Foregound method doesnt

Can someone help on this? dynamicLinks()
.getInitialLink() is working properly. but dynamicLinks()
.onLink is not getting called when app is in foreground state. someone?

+1..

Facing the same issues

@RishavKumar-3796 This is a closed issue. Please open a new issue following the issue template. Please make sure you are using up to date versions and still reproducing the problem

Can someone help on this? dynamicLinks()
.getInitialLink() is working properly. but dynamicLinks()
.onLink is not getting called when app is in foreground state. someone?

facing same issue

@GhayoorUlHaq

This is a closed issue. Please open a new issue following the issue template. Please make sure you are using up to date versions and still reproducing the problem

Was this page helpful?
0 / 5 - 0 ratings