如果未安装应用程序,则重定向到应用程序商店
Redirects to app store if app is not installed
场景是用户将收到 link 到他的电子邮件。如果用户点击 link,如果应用已经安装,应用应该打开,如果应用没有安装,它应该重定向到应用商店。
我看过深度link的实现,但我相信它也需要在后端进行更多的实现。有人可以帮忙吗?
Redirect to application if installed, otherwise to App Store
经历了这个。有没有更好的方法?
为另一种情况添加了 gif:
在下面的 gif 中,从电子邮件直接导航到应用程序?怎么样?
我的建议是检查 iOS 版本
这里的例子
let url = URL(string: "www.whosebug.com")!
if #available(iOS 10.0, *) {
UIApplication.shared.open(url, options: [:], completionHandler: nil)
} else {
UIApplication.shared.openURL(url)
}
我假设您要通过电子邮件传递的 link 是 https
link。如果是这种情况,为了 iOS 能够将其重定向到您的应用程序,您需要在后端实现 universal links. This implementation requires you to register the domain you want to respond to on your entitlements
file and add an apple-app-site-association 文件。通过这种方式,Apple 可以验证您尝试响应的域确实是您的域。
因此,安装应用程序后,您的域 links 可以通过 deeplinking 调用它。
现在,当没有已安装的应用能够响应特定 https
域 link 时,系统只会在网络浏览器上打开它。因此,您不能强制 iOS 直接在 AppStore 上打开此类 link。您可以做的是在您的网站被访问时检查 运行 设备是否 iOS 并要求系统在 AppStore 上显示您的应用程序。
并请求 iOS 从网站启动 AppStore,您可以使用 itms-apps
:
const iOS = !!navigator.platform && /iPad|iPhone|iPod/.test(navigator.platform);
if (iOS) {
// Just replace `https://` with `itms://` on your app's AppStore link.
window.location.href = "itms://itunes.apple.com/us/app/google-maps-transit-food/id585027354?mt=8";
}
// In this example I'm redirecting to Google Maps app page on AppStore.
注意:这只是一个简单的例子,用来说明这个概念。对于真正的应用程序,您可能希望使用浏览器的设备检测库,例如 mobile-detect.js
场景是用户将收到 link 到他的电子邮件。如果用户点击 link,如果应用已经安装,应用应该打开,如果应用没有安装,它应该重定向到应用商店。
我看过深度link的实现,但我相信它也需要在后端进行更多的实现。有人可以帮忙吗?
Redirect to application if installed, otherwise to App Store
经历了这个。有没有更好的方法?
为另一种情况添加了 gif:
在下面的 gif 中,从电子邮件直接导航到应用程序?怎么样?
我的建议是检查 iOS 版本 这里的例子
let url = URL(string: "www.whosebug.com")!
if #available(iOS 10.0, *) {
UIApplication.shared.open(url, options: [:], completionHandler: nil)
} else {
UIApplication.shared.openURL(url)
}
我假设您要通过电子邮件传递的 link 是 https
link。如果是这种情况,为了 iOS 能够将其重定向到您的应用程序,您需要在后端实现 universal links. This implementation requires you to register the domain you want to respond to on your entitlements
file and add an apple-app-site-association 文件。通过这种方式,Apple 可以验证您尝试响应的域确实是您的域。
因此,安装应用程序后,您的域 links 可以通过 deeplinking 调用它。
现在,当没有已安装的应用能够响应特定 https
域 link 时,系统只会在网络浏览器上打开它。因此,您不能强制 iOS 直接在 AppStore 上打开此类 link。您可以做的是在您的网站被访问时检查 运行 设备是否 iOS 并要求系统在 AppStore 上显示您的应用程序。
并请求 iOS 从网站启动 AppStore,您可以使用 itms-apps
:
const iOS = !!navigator.platform && /iPad|iPhone|iPod/.test(navigator.platform);
if (iOS) {
// Just replace `https://` with `itms://` on your app's AppStore link.
window.location.href = "itms://itunes.apple.com/us/app/google-maps-transit-food/id585027354?mt=8";
}
// In this example I'm redirecting to Google Maps app page on AppStore.
注意:这只是一个简单的例子,用来说明这个概念。对于真正的应用程序,您可能希望使用浏览器的设备检测库,例如 mobile-detect.js