简体   繁体   English

iOS Smart App Banners-在iPad和iPhone上显示不同的应用程序

[英]iOS Smart App Banners - showing different app on iPad and on iPhone

I have 2 iOS Apps published on Apple App Store, one is an iPhone App and the other is an iPad App, And I need to use iOS Smart App Banners on my website, so I included 2 meta tags for both applications. 我在Apple App Store上发布了2个iOS应用程序,一个是iPhone应用程序,另一个是iPad应用程序,并且我需要在我的网站上使用iOS Smart App Banners,所以两个应用程序都包含2个meta标签。

<meta name="apple-itunes-app" content="app-id=iPhoneAppID" />
<meta name="apple-itunes-app" content="app-id=iPadAppID" />

And I was expecting that the browser should know the correct app to display to the user whenever he visit my website, but it didn't. 而且我期望浏览器应该知道正确的应用程序,以便用户每次访问我的网站时都能显示给用户,但事实并非如此。

So what I need is a way to show the iPhone app in the iOS Smart App Banners if the use is visiting from iPhone browser, and the iPad app if he is visiting from iPad browser. 因此,我需要一种方法来在用户通过iPhone浏览器访问时在iOS Smart App Banners中显示iPhone应用程序,以及如果用户从iPad浏览器访问时在iPad应用程序中显示iPad应用程序。

OK, I think I found the solution, but it's not from Apple, and it's a jQuery Plugin: http://www.dunnsolutions.com/content/application-development-blog/-/blogs/smart-app-banners-for-ios-and-android 好的,我想我找到了解决方案,但这不是来自Apple的,而是jQuery插件: http : //www.dunnsolutions.com/content/application-development-blog/-/blogs/smart-app-banners-for -ios-和机器人

"If you have two versions of apps in the App Store (for example, one for iPad and another for iPhone/iPod), you may use JavaScript to check the browser's user agent and determine the appropriate meta tag to insert into head of your web page." “如果您在App Store中有两个版本的应用程序(例如,一个版本用于iPad,另一个版本用于iPhone / iPod),则可以使用JavaScript检查浏览器的用户代理,并确定要插入到网站头部的适当元标记页。”

if ( /(iPad).*AppleWebKit.*Mobile.*Safari/.test(navigator.userAgent) ) {
  var headNode = document.getElementsByTagName("head")[0];
  var sbNode = document.createElement('meta');
  sbNode.name = 'apple-itunes-app';
  sbNode.content = 'app-id=your-iPadAppId';
  headNode.appendChild(sbNode);
} else if ( /(iPhone|iPod).*AppleWebKit.*Mobile.*Safari/.test(navigator.userAgent) ) {
  var headNode = document.getElementsByTagName("head")[0];
  var sbNode = document.createElement('meta');                    
  sbNode.name = 'apple-itunes-app';                
  sbNode.content = 'app-id=your-iPhoneAppId';
  headNode.appendChild(sbNode);
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM