最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

How do I detect, via javascript in Safari Mobile, if my iPhone application is installed? - Stack Overflow

programmeradmin3浏览0评论

As you probably know, iPhone applications can register a custom URL scheme handler, ala "myapp:" and these can be used for links in a page viewed in Safari.

I'd like to automatically launch my application from a specific page if the visitor has the app installed. If the app's not installed, I'll just show them the current mobile-optimized view of the page.

How can I do this detection? Google searches have been fruitless. Also, to be tricky, I've tried doing something like this to no avail:

var image = new Image();
image.onerror = function(e){
  alert("bummer");
}
image.onload = function(e){
  alert('success!');
}
image.src = 'myapp://something=meaningful';

Has anyone e across a way to do application detection?

As you probably know, iPhone applications can register a custom URL scheme handler, ala "myapp:" and these can be used for links in a page viewed in Safari.

I'd like to automatically launch my application from a specific page if the visitor has the app installed. If the app's not installed, I'll just show them the current mobile-optimized view of the page.

How can I do this detection? Google searches have been fruitless. Also, to be tricky, I've tried doing something like this to no avail:

var image = new Image();
image.onerror = function(e){
  alert("bummer");
}
image.onload = function(e){
  alert('success!');
}
image.src = 'myapp://something=meaningful';

Has anyone e across a way to do application detection?

Share Improve this question asked Jul 16, 2009 at 0:40 davemyrondavemyron 2,5423 gold badges24 silver badges33 bronze badges 2
  • 3 not possible... sorry dude :-/ Unfortunately, this could be used to do all kinds of bad things. It would be an advertisers jackpot :-) – Ben Gotow Commented Jul 16, 2009 at 4:18
  • @BenGotow do you know how Android does this without all kinds of bad things happening? – Shane Commented Jun 4, 2015 at 23:16
Add a ment  | 

2 Answers 2

Reset to default 6

The solution I've presented on another Stack Overflow question is about as close as you're going to get.

I don't think this is possible. You would need to register your app on the iPhone/Mobile Safari and then create a uri to fire your app up, just like http:, ftp: mailto:. So in your case you would have something like Am I installed Mobile Safari would need to know what app to fire up to load that URI and I just don't think this functionality is built into the iPhone. I know there is no way javascript can query your iPhone to see what's installed.

I hope I am wrong as this seems like it would be a powerful feature, though on the other side I can see some security issues related to something like this.

Good luck.

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论