我正在尝试通过 URL(通过电子邮件等共享)启动我的本机应用程序。 Android 似乎只响应 HTTP 深层链接 URL(例如,http://myapp.com/stuff),并且 iOS 仅响应非 HTTP 自定义深层链接 URL(例如 myapp://stuff)。有没有人找到一个解决方案来使两个操作系统都可以打开相同的 URL?
另外,iOS 是否可以使用 HTTP 深层链接 URL?类似于如何http://youtu.be将打开本机 iOS 应用程序。 Facebook 也这样做。
谢谢! :)
这篇文章对“iOS 和 Android 的 URL 方案”很有用:http://fokkezb.nl/2013/09/20/url-schemes-for-ios-and-android-2/
编辑:
主要思想是向用户发送网站链接。使用服务器上的平台检测我们可以返回正确的链接:
function open() {
// If it's not an universal app, use IS_IPAD or IS_IPHONE
if (IS_IOS) {
window.location = "myapp://view?id=123";
setTimeout(function() {
// If the user is still here, open the App Store
if (!document.webkitHidden) {
// Replace the Apple ID following '/id'
window.location = 'http://itunes.apple.com/app/id1234567';
}
}, 25);
} else if (IS_ANDROID) {
// Instead of using the actual URL scheme, use 'intent://' for better UX
window.location = 'intent://view?id=123#Intent;package=my.app.id;scheme=myapp;launchFlags=268435456;end;';
}
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)