gpt4 book ai didi

android - iOS 和 Android 共享 HTTP 深度链接?

转载 作者:可可西里 更新时间:2023-11-01 02:59:38 26 4
gpt4 key购买 nike

我正在尝试通过 URL(通过电子邮件等共享)启动我的 native 应用程序。 Android 似乎只响应 HTTP 深层链接 URL(例如 http://myapp.com/stuff),而 iOS 只响应非 HTTP 自定义深层链接 URL(例如 myapp://stuff)。有没有人找到一个单一的解决方案来使两个操作系统打开相同的 URL?

此外,iOS 是否可以使用 HTTP 深层链接 URL?类似于http://youtu.be将打开 native 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;';
}
}

关于android - iOS 和 Android 共享 HTTP 深度链接?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29435029/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com