-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
[🐛] getInitialLink() returns null if called too soon after launch [workaround possible! see comments] #4548
Comments
This has been noticed before and is an issue. |
Me too, after update to version 10.0.0. Working on 6.4.0. |
@bachlongkocanh there were by my count 10 dynamic links releases between 6.4.0 and 10.0.0 and your report does not indicate which platform (ios or android, or both?) so is unfortunately not that informative. You also don't indicate which version of the underlying firebase-ios-sdk / firebase-android-sdk you are using. If you could bisect which version of the package and/or underlying SDK you were using to see when it breaks, that would perhaps isolate exactly which commit or version created the change |
Hello 👋, to help manage issues we automatically close stale issues.
|
I'm having almost the same issue on iOS 14: the initialLink is null when running the application in release mode is the app is closed and launched by tapping on the dynamic link. |
Solved it by adding to AppDelegate.m: #import <RNFBDynamicLinksAppDelegateInterceptor.h>
|
Hello :) I'm facing similar issue as well. Here's the description: Sometimes Versions: RN: 0.64.0 I've also tried to upgrade to latest, but the issue was there as well. Also I would like to try the comment above, but when I put @mikehardy any suggestions? One more thing I've noticed. Long Dynamic Links always work. Issue happens only for the short |
Hello 👋, to help manage issues we automatically close stale issues.
|
Not stale, has great info, needs time to investigate, thanks for the patience all involved |
Here's a solution that worked for us. It's just a function that tries to get the dynamic link multiple times with a 500ms interval between the calls. It works pretty well. import dynamicLinks, { FirebaseDynamicLinksTypes } from '@react-native-firebase/dynamic-links';
const getInitialLink = (
maxAttempts: number,
): Promise<null | FirebaseDynamicLinksTypes.DynamicLink> => new Promise((resolve) => {
let link: null | FirebaseDynamicLinksTypes.DynamicLink = null;
const getLink = async (attempt: number = 1) => {
try {
link = await dynamicLinks().getInitialLink();
} catch (e) {
// Try again
}
if (link) {
resolve(link);
} else if (attempt <= maxAttempts) {
setTimeout(() => {
getLink(attempt + 1);
}, 500);
} else {
resolve(null);
}
};
getLink();
});
// And somewhere in a `useEffect` hook:
getInitialLink(20).then((link) => {
if (link) {
// handleDynamicLink(link);
}
}); |
It is still actual "react-native": "0.66.1" ios: 15.3.1 I`m disagreed with @s-aleinik - a long link also does not work |
This is still happening on iOS release builds and the workaround stated above (delaying retrieval of dynamic links) works for me. |
For anyone else here using Expo with React native. The issue we had was on the frontend with getting the initialUrl. Instead use React Native Linking library. like this: https://reactnative.dev/docs/linking - we added the event listener then like in the docs and everything worked a treat! |
@kierandesmond Does that solution allow the link to survive the app install process? I could be wrong on this but I'm pretty sure the firebase sdk's have special logic for checking the pasteboard on first run. |
Has anyone encountered varying dynamic link behavior between different Android phone models? Looking around I'm seeing many running into getInitialLink() issues on iOS but I've got something different going on. On iOS and a Google Pixel 4a getInitialLink() works every time. But when installing on my Samsung Galaxy S21 getInitialLink() returns null every other install consistently(first attempt: null, second attempt: correct link, third attempt: null, etc...). This wouldn't be so much of an issue as real users aren't going to be installing the app repeatedly with our QR codes except that it also consistently returns null on the first install after a restart, which makes me worry that it may fail for every user. Any guesses on what causes the difference between these two devices? It's possible it's a quirk in my dev environment - I do the majority of my development on the Pixel. |
I am also seeing this exact behaviour as @erikmillergalow with getInitialLink on a Samsung S8 Tablet. if I delay my call to getInitialLink() by, say, 10 milliseconds (via setTimeout) then it works every time. Any ideas? |
Hello. "@react-native-firebase/dynamic-links": "15.2.0" Finally, I was able to solve it by adding code to AppDelegate.m.
My solution is to call As far as I have tested, swizzing is enabled by calling the However, in the Release build, Originally, |
The workaround here ☝️ of directly instantiating the interceptor, so that it is swizzled properly and then intercepts links correctly - has received some testing and appears to work well, per feedback in #2660 - a related issue. apparently the swizzling on the dynamic links interceptor does not happen soon enough some times, so it does not intercept the link, but forcing it to init as the workaround does corrects this so there is no longer a race condition |
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
Hello 👋, to help manage issues we automatically close stale issues. This issue has been automatically marked as stale because it has not had activity for quite some time.Has this issue been fixed, or does it still require attention?
Thank you for your contributions. |
Same issue |
@mikehardy |
The workaround provided is causing following issue while doing Build -> Archive
I am using react-native-firebase with |
"I am having trouble compiling and building things"
"I am using an unsupported configuration with a workaround that has been explicitly declared problematic when it comes to compiling and building things" |
"@react-native-firebase/dynamic-links": "17.3.1" My team and I tried to use the suggested solution for React Native (non-Expo), and it didn't work. The initial link was always null. What's working for us is to use the suggested solution with issuecomment-762881871 - plus a bit of an update on the Our
|
Make sure you include #import <RNFBDynamicLinksAppDelegateInterceptor.h> before #if RCT_NEW_ARCH_ENABLED |
Hello 👋, to help manage issues we automatically close stale issues. This issue has been automatically marked as stale because it has not had activity for quite some time.Has this issue been fixed, or does it still require attention?
Thank you for your contributions. |
Hello, did someone find a solution ? i tried the workaround mentionned but url is still null. Struggling for 3 days now on both ios and android, cannot figure out how to deal with that. If someone has a working example that would be nice :) |
Hello 👋, to help manage issues we automatically close stale issues. This issue has been automatically marked as stale because it has not had activity for quite some time.Has this issue been fixed, or does it still require attention?
Thank you for your contributions. |
@tilted-tm @mishijima @mikehardy Firebase Dynamic Link will be shut down soon https://firebase.google.com/support/dynamic-links-faq?hl=en&authuser=0 |
@bhalodiya-vivek, interesting. Thank you very much for this info! 🙇 |
Hello 👋, to help manage issues we automatically close stale issues. This issue has been automatically marked as stale because it has not had activity for quite some time.Has this issue been fixed, or does it still require attention?
Thank you for your contributions. |
Still got this issue even when I applied a workaround. |
Whenever I hit the link, it opens Safari not the app. i even opened the link from the notes app and it did not go :( |
@ammarkden hey there 👋 - a couple things 1- that doesn't sound like the original issue, so it's a thread hijack, 2- dynamic links is deprecated, so I'd be very careful implementing a dynamic-links-based solution right now. As a firebase module it will not be receiving further updates and it will be shut down That last bit is not great to hear (I have apps that use dynamic links! I'm sad to see it go as I don't want to reengineer the app linking...) but it's important to know. I would use standard react-native (or Expo) linking https://reactnative.dev/docs/linking |
Thanks man I was stuck for days <3 |
EDIT: it appears the workaround below is successful #4548 (comment)
Issue
When my iOS app is completely closed and I use a dynamic link to open the app, getInitialLink returns null if I do it too soon. If I wait a bit it will return the link content correctly. I haven't figured out a way to make sure that the method is ready to be called. Currently I am calling it in useEffect and sometimes I get null and sometimes it works as expected, but I can't get it to work reliably without adding a considerable timeout (something like 1000ms) before calling it. So the functionality definitely works so my setup is fine but there just doesn't seem to be a way to reliably know when I can use getInitialLink.
The text was updated successfully, but these errors were encountered: