当应用程序尚未安装在设备中时,如何修复 iOS 中的深度链接?
How to fix deep linking in iOS when the application has not installed in the device?
我正在为 android 和 iOS 使用深度 linking 功能,我的后端在 CI 中。安装应用程序时,深度 linking 对 Android 和 iOS 都有效。但是如果应用程序还没有安装,那么我就会遇到问题。
我试过这样:
当任何用户单击 link 时,首先它将重定向到浏览器,然后从我的后端代码检查客户端设备类型。如果设备是 Android 那么我将它重定向到 Android 应用程序,如果设备是 iOS 然后它重定向到 iOS 应用程序。
但是当应用程序还没有安装时,它就停止工作了。
对于Android,我输入了以下代码:
header("Location: my.special.scheme://other/parameters/here")
为iOS在URL之前添加了申请方案。
我想我已经描述了我所有的情景。请指导我如何在未安装应用程序时将其重定向到应用程序商店或特定页面。
基本上,您尝试使用上面提供的 URI 方案 (my.special.scheme://other/parameters/here
) 深入 link,但由于未安装该应用程序而失败。在那种情况下,您无法捕获失败并将用户重定向到其他地方。
您可以将您的 BE 设置为 return 与此类似的内容:
window.location.href = "my.special.scheme://other/parameters/here";
setTimeout(function () {
window.location.href = ...store_link_for_your_app..;
}, 1000);
这样,如果 deep link 失败,1 秒后您将获得重定向。
重要提示:
- 并非所有浏览器都支持深度 link 通过 URI 方案。例如,在 Chrome 中,这将失败。在这里你必须使用 Intents,参见 https://developer.chrome.com/multidevice/android/intents
- 在 iOS 9+ 中,如果未安装该应用程序,Safari 浏览器将阻止使用 URI 方案 - 您将在屏幕上收到有关 URL 有效性的错误消息。在这里您需要实施通用链接,请参阅 https://developer.apple.com/ios/universal-links/
希望对大家有所帮助:
var deeplinkUrl = `yourscheme://myurl?param1=x¶m2=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;
}
我正在为 android 和 iOS 使用深度 linking 功能,我的后端在 CI 中。安装应用程序时,深度 linking 对 Android 和 iOS 都有效。但是如果应用程序还没有安装,那么我就会遇到问题。
我试过这样: 当任何用户单击 link 时,首先它将重定向到浏览器,然后从我的后端代码检查客户端设备类型。如果设备是 Android 那么我将它重定向到 Android 应用程序,如果设备是 iOS 然后它重定向到 iOS 应用程序。 但是当应用程序还没有安装时,它就停止工作了。
对于Android,我输入了以下代码:
header("Location: my.special.scheme://other/parameters/here")
为iOS在URL之前添加了申请方案。
我想我已经描述了我所有的情景。请指导我如何在未安装应用程序时将其重定向到应用程序商店或特定页面。
基本上,您尝试使用上面提供的 URI 方案 (my.special.scheme://other/parameters/here
) 深入 link,但由于未安装该应用程序而失败。在那种情况下,您无法捕获失败并将用户重定向到其他地方。
您可以将您的 BE 设置为 return 与此类似的内容:
window.location.href = "my.special.scheme://other/parameters/here";
setTimeout(function () {
window.location.href = ...store_link_for_your_app..;
}, 1000);
这样,如果 deep link 失败,1 秒后您将获得重定向。
重要提示:
- 并非所有浏览器都支持深度 link 通过 URI 方案。例如,在 Chrome 中,这将失败。在这里你必须使用 Intents,参见 https://developer.chrome.com/multidevice/android/intents
- 在 iOS 9+ 中,如果未安装该应用程序,Safari 浏览器将阻止使用 URI 方案 - 您将在屏幕上收到有关 URL 有效性的错误消息。在这里您需要实施通用链接,请参阅 https://developer.apple.com/ios/universal-links/
希望对大家有所帮助:
var deeplinkUrl = `yourscheme://myurl?param1=x¶m2=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;
}