有关我们的iPhone本机应用程序,我们有一个网址:例如://
For our iPhone native application we have a URL : example://
在iPhone上,如果我键入此网址(例如://)。在Safari会自动打开了我的申请。
On the iPhone if I type this URL (example://) in safari it automatically opens up my application.
这是我的正规的网站我有当用户点击可以打开应用程序的链接。问题是,如果应用程序没有在iPhone上安装它会抛出无法打开的错误。
From my "regular" website I have a link which when the user clicks it opens the application. The problem is that if the application is not installed on the iPhone it throws "Unable to open" error.
所以呈现在我的正规的网站上的链接之前,我需要检查是否安装了应用程序,一种解决方案是使一个Ajax调用,并检查状态code:
So before rendering the link on my "regular" site I need to check if the app is installed, one solution is to make an Ajax call and check for status code:
$.ajax({
type: 'POST',
url: 'example://',
complete: function (transport) {
if (transport.status == 200) {
alert('Success');
} else {
alert(transport.status);
alert('Failed');
}
}
});
但是,这code总是返回一个状态code0。
But this code is always returning a status code "0".
有没有办法从网上了解是否安装了原生iPhone应用程序?
Is there a way to find out from the web if the native iPhone app is installed?
如果妳指的是移动Safari浏览器,你的运气了。有没有记录的公共API,我知道的,可以做到这一点。移动Safari浏览器从操作系统的沙盒了。
If u are referring to Mobile Safari, you're out of luck. There's no documented public API that I know of that can do this. Mobile Safari is sandboxed away from the OS.
如果它在一个web视图中的一个应用程序,U可以请求的URL,让web视图代表谈话的本机应用程序/查询例子的处理://。否则,没办法浏览器就可以知道存在任何已安装的应用程序。
If it's in a webview within an app, u can request the URL and let the webview delegate talk to the native app / query the handling of example://. Otherwise, no way the browser can know existence of any installed app.