从 Web 应用程序启动本机应用程序时出错 - iOS - 无法显示 URL
我在尝试从我的 Web 应用程序(支持 apple-mobile-web-app-capable)调用我的本机 iOS 应用程序时遇到了一些麻烦。每当我在 Safari 中按下按钮以使用自定义 URL 方案打开我的应用程序时,效果都很好。
但是,当我将其添加到主屏幕时,我遇到了错误:无法显示 URL。重定向到 http 或 https 工作正常,但如果我调用 mysupercustomurlscheme:// 我会收到上面的错误消息。
我尝试通过 document.location.href、window.location 等打开它,但似乎没有任何效果,我已经没有想法了。
如果有人有任何想法,我将非常感激听到他们的声音。
提前致谢!
I'm running into a bit of trouble trying to call my native iOS application from my web app (apple-mobile-web-app-capable). Whenever I'm in Safari pressing the button to open my app with a custom url scheme, that works just fine.
However, when I've added it to the home screen I get stuck with the error: The URL can't be shown. Redirecting to http or https works fine but if I call mysupercustomurlscheme:// I get the error message above.
I've tried opening it by document.location.href, window.location, etc etc but nothing seems to do the trick and I've run out of ideas.
If anyone has got any ideas I'd be most grateful to hear them.
Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
好吧,这是一个有点笨拙的方法,但它有效,并且可能会帮助一些可怜的人尝试实现同样的目标。
首先,创建一个简单的 HTML 链接,显然,常规 HTML 链接是在 Mobile Safari 中打开,而不是在 Web 应用程序的全屏视图中打开。
链接
在redirect.html 中,您只需使用一些简单的javascript 重定向用户即可。
window.location = "mysupercustomurlscheme://"
就是这样!这当然不是最好的方法,但它“相当”无缝。至少这是我想到的,如果您有任何其他建议请告诉我。
希望这对某人有帮助!
Okay, here's a somewhat clumsy way to do it, but it works and might help some poor soul out there trying to achieve the same thing.
First, create a simple HTML link as, apparently, regular HTML links open in Mobile Safari instead of within the full screen view in the web app.
Link
In redirect.html you simply redirect the user with some simple javascript.
window.location = "mysupercustomurlscheme://"
And that's it! It's certainly not the best way to do it but it's 'fairly' seamless. That's what I came up with at least, if you have any other suggestions do let me know.
Hope this helps someone!
只是想发布托比亚斯引用的示例。您需要托管在您的服务器上并链接到电子邮件、社交媒体等。只需替换您应用的 URI 和您的 App Store 链接。请注意,iframe 适用于更多浏览器。
因此,如果用户安装了您的应用程序,则与 URI 的链接将会成功,并且您将在触发用于重定向到 App Store 的脚本之前退出浏览器。如果用户没有您的应用程序,则重定向成功(在出现简短的丑陋错误消息之后)。我是 Branch 的开发人员,我们使用它,因此请随时与我们联系以解决实施中的问题。
Just wanted to post an example of what Tobias is referencing. You need to host on your server and link to in emails, social media, etc. Simply substitute in your app's URI and your App Store link. Note that the iframe works on more browsers.
So, if the user has your app installed, the link with the URI will succeed and you will exist the browser before the script for redirecting to the App Store can be triggered. If the user does not have your app, the redirect succeeds (after a brief ugly error message). I am a developer at Branch and we use this, so feel free to reach out with questions in implementing.