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

🔥 Dynamic Links keeps returning the same url on different links #2631

Closed
2 of 5 tasks
SimonErich opened this issue Sep 25, 2019 · 12 comments
Closed
2 of 5 tasks

🔥 Dynamic Links keeps returning the same url on different links #2631

SimonErich opened this issue Sep 25, 2019 · 12 comments

Comments

@SimonErich
Copy link

SimonErich commented Sep 25, 2019

Issue

Hi we have a problem with multiple dynamic links opening.
We have multiple dynamic link entry points in our app.

The problem is, that currently (after update to update to dynamicLinks in 6.0.0) it seems like we always get the same link from getInitialLink().

Reproduction:
This is how we can reproduce it:

  • I create 2 different dynamic links
  • I open the first link and everything works fine ( i get the correct url )
  • I open the second link (while the app is open in background) -> getInitialLink() is triggered and I only get the first link again

If I close the app before I open the second link and click then, I get the correct link.

Additional info:
We also implemented the onLink subscriber, but it is never triggered, as I would have thought.
I guess it makes sense that getInitialLink stays the same, as it was, when we opened the app the first time, but then I would expect the subscriber to trigger.

This is how we init the package: (we call this method in componentDidMount in App.tsx)

  initDynamicLinks() {
    dynamicLinks()
      .getInitialLink()
      .then((urlObj: DynamicLinks.DynamicLink | null) => {
        if (urlObj) {
          this.handleDynamicLink(urlObj.url);
        }
      });

    this.dynamicLinkListener = dynamicLinks().onLink((url: string) => {
      this.handleDynamicLink(url);
    });
  },


Project Files

iOS

Android

Environment

Click To Expand

react-native info output:

System:
    OS: Linux 5.0 Ubuntu 19.04 (Disco Dingo)
    CPU: (8) x64 Intel(R) Core(TM) i7-4770S CPU @ 3.10GHz
    Memory: 2.05 GB / 31.29 GB
    Shell: 5.5.1 - /usr/bin/zsh
  Binaries:
    Node: 12.4.0 - ~/.nvm/versions/node/v12.4.0/bin/node
    Yarn: 1.16.0 - ~/.nvm/versions/node/v12.4.0/bin/yarn
    npm: 6.9.0 - ~/.nvm/versions/node/v12.4.0/bin/npm
  npmPackages:
    react: 16.8.6 => 16.8.6 
    react-native: 0.60.4 => 0.60.4 
  npmGlobalPackages:
    react-native-cli: 2.0.1
  • Platform that you're experiencing the issue on:

    • iOS
    • Android
    • iOS but have not tested behavior on Android
    • Android but have not tested behavior on iOS
    • Both
  • react-native-firebase version you're using that has this issue:

    • 0.5.4
  • Firebase module(s) you're using that has the issue:

    • DynamicLinks
  • Are you using TypeScript?

    • Y

@SimonErich SimonErich changed the title 🔥 Dynamic Links keeps returning the same url on different urls 🔥 Dynamic Links keeps returning the same url on different links Sep 25, 2019
@sammcoe
Copy link

sammcoe commented Sep 28, 2019

I also had this problem when upgrading to version 6-- just for kicks I tried throwing the normal RN Linking setup and using Linking.addEventListener() and it worked.

https://facebook.github.io/react-native/docs/linking

I stripped all the old configuration from before the upgrade, because there's no longer mention of it in the docs.

@ram95krishh
Copy link

Not meaning to trivialize your issue, but could you please check if you had previously edited an existing deep link into a dynamic link in the Notes app, from where you would have tested your Dynamic link. In some cases the Notes app retains an old hyperlink value for links that get modified. I faced this issue and it took me one full day before figuring out that it was something as simple as this.

@SimonErich
Copy link
Author

SimonErich commented Oct 7, 2019

I managed to solve this problem by adding launchMode="singleTask" to the .MainActivity

    <activity
      ....
      android:name=".MainActivity"
      ....
      android:launchMode="singleTask"
    >

See:
#1084 (comment)

@ankitwandx
Copy link

I am having the same issue on iOS. any solution?

@FickleLife
Copy link

FickleLife commented Jan 6, 2021

I am also having this issue. getInitialLink() is always returning the same "first" url that opened the app initially, not the latest url that also caused the app to open. I am using Flutter and firebase_dynamic_links: ^0.6.3

@mikehardy
Copy link
Collaborator

Hi there @FickleLife - while Invertase works on FlutterFire and React Native Firebase the repos are pretty different and worked on separately (even if by the same people). You should definitely post an issue over there

@dochonglo
Copy link

dochonglo commented Jan 28, 2021

OP, have you or anyone else been able to find a solution to this issue? The getInitialLink() method keeps on returning the same link even if I click on different dynamic links. The link only changes when I quit the app and click on a new link. Only then, the getInitialLink() method returns a new link.

I'm also using DynamicLinks from Firebase. Below is information regarding my environment:

  • @react-native-firebase/app": "^10.5.0
  • @react-native-firebase/dynamic-links": "^10.5.1
  • Running on iOS
  • Not using Typescript.
Expo CLI 4.0.17 environment info:
  System:
   OS: macOS 11.1
   Shell: 3.2.57 - /bin/bash
  Binaries:
   Node: 14.5.0 - /usr/local/bin/node
   Yarn: 1.21.1 - /usr/local/bin/yarn
   npm: 6.13.7 - ~/.npm-global/bin/npm
   Watchman: 4.9.0 - /usr/local/bin/watchman
  Managers:
   CocoaPods: 1.10.0 - /usr/local/bin/pod
  SDKs:
   iOS SDK:
    Platforms: iOS 14.3, DriverKit 20.2, macOS 11.1, tvOS 14.3, watchOS 7.2
  IDEs:
   Android Studio: 4.1 AI-201.8743.12.41.6953283
   Xcode: 12.3/12C33 - /usr/bin/xcodebuild
  npmPackages:
   expo: ~40.0.0 => 40.0.0 
   react: 16.13.1 => 16.13.1 
   react-dom: 16.13.1 => 16.13.1 
   react-native: ~0.63.4 => 0.63.4 
   react-native-web: ~0.13.12 => 0.13.18 
   react-navigation: ^4.0.10 => 4.0.10 
  npmGlobalPackages:
   expo-cli: 4.0.17
  Expo Workflow: bare

Thanks in advance!! :)

@mikehardy
Copy link
Collaborator

I think you want to listen to onLink once the app is already running? getInitialLink is only for the first link that caused the app to start

@dochonglo
Copy link

dochonglo commented Jan 28, 2021

I think you want to listen to onLink once the app is already running? getInitialLink is only for the first link that caused the app to start

Well, if the app is in the background, then by definition, shouldn't getInitialLink() always return the link that last opened the app? I don't quite understand why the function will always return the first link that opened the app.

Imagine the following scenario. If a friend sends you 3 Instagram stories through iMessages and you tap on the first link, you should see the first IG story shared with you. If you leave Instagram, go back to iMessages, and tap on the second link (technically, Instagram is now in the background and iMessages is in the foreground), then you should now see the second IG story--not the first.

Unfortunately, if we're using getInitialLink()--as it's working right now--in the above example, we'll always see the first IG story shared rather than any one three that we click on. However, if we're using the technical definition as stated in the RNFirebase Documentation, then each time the app goes into the background, the getInitialLink() method should be returning a brand new (and the most current) link that opened the app.

Also, onLink() wouldn't make sense in this example as well, since we're constantly moving back and forth between the Instagram and iMessages app as onLink() is only triggered when the app is in the foreground.

Namely, I'd like to be able to detect what links are bringing users into the app. How would I go about doing so?

@mikehardy
Copy link
Collaborator

did onLink fire?

@dochonglo
Copy link

No, unfortunately, the onLink method did not fire, because technically, I had left the app (it's not foregrounded anymore).

@Usamaliaquat123
Copy link

i got the soluttion, you guys doing something like this
dynamicLinks() .getInitialLink() : Promis <void>

try to import the Linking pkg from react-native

on componentDidMount()

add Linking.addEventListener('verify', (e) => { console.log(e); });

on your console you will get the latest link with their params

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

8 participants