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

bug: Deferred Deeplink not working and App.getLaunchUrl() return undefined. #6480

Open
Saqib92 opened this issue Apr 10, 2023 · 8 comments
Open

Comments

@Saqib92
Copy link

Saqib92 commented Apr 10, 2023

Bug Report

Capacitor Version

💊   Capacitor Doctor  💊 

Latest Dependencies:

  @capacitor/cli: 4.7.3
  @capacitor/core: 4.7.3
  @capacitor/android: 4.7.3
  @capacitor/ios: 4.7.3

Installed Dependencies:

  @capacitor/cli: 3.2.2
  @capacitor/core: 3.2.2
  @capacitor/ios: 3.2.2
  @capacitor/android: 3.2.2

[success] iOS looking great! 👌
[success] Android looking great! 👌

Platform(s)

Android
iOS

Current Behavior

App.getLaunchUrl() return undefined.

Expected Behavior

it should return deferred deeplink when coming from playstore or app store after installing application.

Code Reproduction

async getAppLaunch(){
    const launchUrl = await App.getLaunchUrl();
    console.log(launchUrl)
    if (launchUrl && launchUrl.url) {
      // parse the launchUrl URL to extract the deep link data
      const deepLinkData = new URLSearchParams(launchUrl.url.split('?')[1]);
      console.log(deepLinkData.get('ddl')); // prints "mydeeplinkdata"
    }
  }

Other Technical Details

I am implementing deferred deeplink when user clicks on my link it and they dont have app installed it will take them to respective store after installation App.getLaunchUrl() is not returning original clicked link.

User clicks on this link which takes them to playstore:
https://play.google.com/store/apps/details?id=com.example.myapp&deeplinkdata=mydeeplinkdata
after installation how can i get data in my app?
Normal deeplinks are working. if user have app installed and click any link it open my app and takes them to respective content / page.

npm --version output: 9.3.1

node --version output: v16.13.1

pod --version output (iOS issues only): 1.11.3

Additional Context

i tried to setup play.google.com as my intent filter.
tried this ADC Command
adb shell am start -W -a android.intent.action.VIEW -d "https://play.google.com/store/apps/details?id=com.example.myapp&ddl=mydeeplinkdata" com.example.myapp

Nothing is working. haven't tried on ios but i need this for iOS Too.

@kpturner
Copy link

It is very disappointing that nobody has responded to this at all. The implication is that "deferred" deeplinks are not possible without a third party like AppsFlyer or Branch.io or some other home made solution. @Saqib92 did you reach a conclusion yourself?

@Saqib92
Copy link
Author

Saqib92 commented Sep 20, 2023

It is very disappointing that nobody has responded to this at all. The implication is that "deferred" deeplinks are not possible without a third party like AppsFlyer or Branch.io or some other home made solution. @Saqib92 did you reach a conclusion yourself?

I ended up using AppsFlyer SDK.

@kpturner
Copy link

kpturner commented Sep 20, 2023

Out of interest did the vanilla capacitor solution work correctly when a "normal" deeplink was clicked and the app was not already installed? I mean did it automatically take the user to the relevant store to install the app even though the app had no clue what the details of the deeplink were when it started up?

@Saqib92
Copy link
Author

Saqib92 commented Sep 20, 2023

Out of interest did the vanilla capacitor solution work correctly when a "normal" deeplink was clicked and the app was not already installed? I mean did it automatically take the user to the relevant store to install the app even though the app had no clue what the details of the deeplink were when it started up?

I have no idea as i already had a website ready. If user have no app installed it will go to website version of that link. You can add install app link on your website.

@kpturner
Copy link

Oh I see - no I am referring to the type of deferred deep-link that the likes of AppFlyer and branch.io provide where, if clicked on a mobile device, will open the app if installed or go to the store (for the app to be installed) before doing so.

It sounds like you have implemented something different.

@terencehonles
Copy link

I hadn't heard of this, but it seems like those services are using https://developer.android.com/google/play/installreferrer/library / https://developers.google.com/analytics/devguides/collection/android/v4/campaigns for Android at least.

I would not classify this as a bug, because deep links don't imply deferred links which need cooperation from the device's app store to pass whatever parameters caused the install. If there is no communication between the device and the app store (even if it's locally on the device) then there's no way for the app to know how it was installed.

Instead this is a feature to support install referrers and you can see if there's a plugin that already exists that does this, or write your own. Collecting the referrer information looks relatively straightforward and could also be done in your main activity, but I'm not sure how trivial it would be to set the launch URL (you may need to expose this as a plugin method yourself).

@tybro0103
Copy link

Tangent here, but I've noticed this official example here:

const checkAppLaunchUrl = async () => {
  const { url } = await App.getLaunchUrl();
  console.log('App opened with URL: ' + url);
};

Since the result of getLaunchUrl() can be undefined, this is going to throw an error every time the app is launched without a link/url. Perhaps a better example code would be like:

const checkAppLaunchUrl = async () => {
  const launch = await App.getLaunchUrl();
  console.log('App opened with URL: ' + launch?.url);
};

@trinitiwowka
Copy link

Hi! Did you found any solution?

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

No branches or pull requests

6 participants