kudago / smart-app-banner

Lightweight smart app banner with no jquery requirement
MIT License
526 stars 250 forks source link

Does not work on iOS #33

Open avatar opened 9 years ago

avatar commented 9 years ago

Hi, I'm trying to implement this on my site. When I use force: 'ios', I see the banner like I should, but otherwise no banner is appearing :S

I also get no errors

Is this a known issue, or did I do something wrong?

Thanks!

harlanrs commented 9 years ago

In iOS 6 and greater the following meta tag is rendered by safari automatically on page load: <meta name="apple-itunes-app" content="app-id=[APPID]">

Because of this automatic render behavior, this code base has a check for the version (to prevent duplicate banners for appearing): if (agent.os.name === 'iOS' && parseInt(agent.os.version) < 6) {

this line will only be true and load their version of the banner if the user is on a device under iOS 6.

If you are adding the meta tag dynamically with javascript instead of manually inserting it in the head (as was the case with my project), safari won't register the meta tag on page load (because it doesn't exist immediately if it is being inserted by js) and won't show the native version of the banner. In this case, I was able to delete the parseInt(agent.os.version) < 6 and have this library display the banner on any version of iOS (with the added benefit of working on chrome in iOS as well).

marcofugaro commented 7 years ago

Yup, this prevented me from using this plugin, the original one at least has a check

https://github.com/jasny/jquery.smartbanner/blob/master/jquery.smartbanner.js#L35