从Web应用程序启动本机应用程序时出错-iOS-无法显示URL [英] Error launching native application from web app - iOS - URL can't be shown

查看:192
本文介绍了从Web应用程序启动本机应用程序时出错-iOS-无法显示URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试从我的网络应用程序(支持Apple-mobile-web-app的应用程序)中调用本机iOS应用程序时遇到了麻烦.每当我在Safari中按下按钮时,使用自定义网址方案打开我的应用程序,就可以正常工作.

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.

但是,当我将其添加到主屏幕时,我陷入了以下错误:无法显示URL.重定向到http或https可以正常工作,但是如果我调用mysupercustomurlscheme://,则会收到上面的错误消息.

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.

我尝试通过document.location.href,window.location等打开它,但是似乎没有任何办法解决这个问题,并且我的想法已经用完了.

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.

提前谢谢!

推荐答案

好的,这是一种笨拙的方法,但是它可以工作,并且可能会帮助一些可怜的灵魂尝试实现同一目标.

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.

首先,创建一个简单的HTML链接,因为很显然,常规HTML链接是在Mobile Safari中打开的,而不是在Web应用程序的全屏视图中打开的. 链接

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

在redirect.html中,您只需使用一些简单的javascript来重定向用户. window.location ="mysupercustomurlscheme://"

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.

希望这对某人有帮助!

这篇关于从Web应用程序启动本机应用程序时出错-iOS-无法显示URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆