我认为这样做的侵入性最小的方式如下:
- 判断用户代理是否为iPhone/iPod Touch的用户代理
- 判断是否有
appInstalled
个Cookie
- 如果cookie存在且设置为true,则将
window.location
设置为your-uri://
(或重定向服务器端)
- If the cookie doesn't exist, open a "Did you know Your Site Name has an iPhone application?" modal with a "Yep, I've already got it", "Nope, but I'd love to try it", and "Leave me alone" button.
- "Yep"按钮将cookie设置为true并重定向到
your-uri://
- "否"按钮将重定向到"http://itunes.com/apps/yourappname",这将打开设备上的应用store
- "别管我"按钮将cookie设置为false,并关闭模式
我try 过的另一个 Select 是在Javascript中执行以下操作,但觉得有点笨拙:
setTimeout(function() {
window.location = "http://itunes.com/apps/yourappname";
}, 25);
// If "custom-uri://" is registered the app will launch immediately and your
// timer won't fire. If it's not set, you'll get an ugly "Cannot Open Page"
// dialogue prior to the App Store application launching
window.location = "custom-uri://";