简体   繁体   中英

How to fix deep linking in iOS when the application has not installed in the device?

I'm working with deep linking features for android and iOS, my back end is in CI. The deep linking is working for both Android and iOS when the application is installed. But if the application has not been installed then I face the problem.

I have tried it this way: When any user clicks on the link then first it will redirect to the browser, after that from my back end code I am checking that the client device type. If the device is Android then I am redirecting it to Android application, if the device is iOS then it redirect to iOS application. But when the application hasn't been installed, it stops working.

For Android I have put the following code:

header("Location: my.special.scheme://other/parameters/here")

For iOS have added the application scheme just before the URL.

I think I have described all my scenarios. Please guide me how it should be redirected to the app store or the specific page when the application is not installed.

Hope help anyone:

var deeplinkUrl = `yourscheme://myurl?param1=x&param2=y`;
//variable will check app installed or not
var change = false;
setTimeout(() => {
  if (!change) {
    var redirectUrl = "your store url";
    window.location = redirectUrl;
  }
}, 3000);
window.location = deeplinkUrl;
//handle event to check app installed or not
window.onblur = function () {
    change = true;
};
window.onfocus = function(){
    change = false;
}

Basically what happens is that you try to deep link using the URI scheme provided above ( my.special.scheme://other/parameters/here ) and it fails since the app is not installed. In that case you cannot catch the failure and redirect the user elsewhere.

You can set your BE to return something similar to this:

window.location.href = "my.special.scheme://other/parameters/here";
setTimeout(function () {
    window.location.href = ...store_link_for_your_app..;
}, 1000);

That way, if deep link fails, after 1s you'll get a redirect.

Important notes:

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM