当应用程序尚未安装在设备中时,如何修复 iOS 中的深层链接?

Kou*_*Das 4 android codeigniter deep-linking ios

我正在使用 Android 和 iOS 的深度链接功能,我的后端位于 CI 中。安装应用程序后,深度链接适用于 Android 和 iOS。但如果该应用程序尚未安装,那么我就会遇到问题。

我已经尝试过这种方式:当任何用户单击链接时,它首先会重定向到浏览器,然后从我的后端代码检查客户端设备类型。如果设备是 Android,那么我会将其重定向到 Android 应用程序,如果设备是 iOS,那么它会重定向到 iOS 应用程序。但当应用程序尚未安装时,它就会停止工作。

对于 Android,我放置了以下代码:

header("Location: my.special.scheme://other/parameters/here")
Run Code Online (Sandbox Code Playgroud)

对于 iOS,已在 URL 之前添加了应用程序方案。

我想我已经描述了我所有的场景。请指导我如何在未安装应用程序时将其重定向到应用程序商店或特定页面。

Dro*_*idi 8

基本上发生的情况是,您尝试使用上面提供的 URI 方案 ( my.special.scheme://other/parameters/here) 进行深度链接,但由于未安装应用程序而失败。在这种情况下,您无法捕获故障并将用户重定向到其他地方。

您可以将 BE 设置为返回类似于以下内容的内容:

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

这样,如果深层链接失败,1 秒后您将获得重定向。

重要笔记:


vul*_*avi 8

希望对任何人有帮助:

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;
}
Run Code Online (Sandbox Code Playgroud)