是否可以为 YouTube 和地图等 iPhone 应用程序注册基于 http+域的 URL 方案? [英] Is it possible to register a http+domain-based URL Scheme for iPhone apps, like YouTube and Maps?

查看:29
本文介绍了是否可以为 YouTube 和地图等 iPhone 应用程序注册基于 http+域的 URL 方案?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想让 iOS 打开我域中的 URL(例如 http://martijnthe.nl)我的应用程序只要安装在手机上,如果没有安装,请使用 Mobile Safari.

I'd like to have iOS to open URLs from my domain (e.g. http://martijnthe.nl) with my app whenever the app is installed on the phone, and with Mobile Safari in case it is not.

我读到可以为此创建一个唯一的协议后缀并将其注册到 Info.plist 中,但如果未安装该应用程序,Mobile Safari 会出现错误.

I read it is possible to create a unique protocol suffix for this and register it in the Info.plist, but Mobile Safari will give an error in case the app is not installed.

有什么解决方法?

一个想法:

1) 使用在任何桌面浏览器中打开的 http://URL 并通过浏览器呈现服务

1) Use http:// URLs that open in any desktop browser and render the service through the browser

2) 检查用户代理,如果它是 Mobile Safari,请打开 myprotocol://URL 以(尝试)打开 iPhone 应用程序并让它打开 Mobile iTunes 以下载应用程序,以防尝试失败

2) Check the User-Agent and in case it's Mobile Safari, open a myprotocol:// URL to (attempt) to open the iPhone app and have it open Mobile iTunes to the download of the app in case the attempt fails

不确定这是否有效...建议?谢谢!

Not sure if this will work... suggestions? Thanks!

推荐答案

我认为这样做的最少侵入方式如下:

I think the least intrusive way of doing this is as follows:

  1. 检查用户代理是否是 iPhone/iPod Touch 的用户代理
  2. 检查 appInstalled cookie
  3. 如果cookie存在并且设置为true,将window.location设置为your-uri://(或者做重定向服务器端)
  4. 如果 cookie 不存在,请打开您知道您的站点名称有 iPhone 应用程序吗?"带有是的,我已经拿到了"、不,但我很想试试"和别管我"按钮的模态.
  1. Check if the user-agent is that of an iPhone/iPod Touch
  2. Check for an appInstalled cookie
  3. If the cookie exists and is set to true, set window.location to your-uri:// (or do the redirect server side)
  4. 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.
  1. 是"按钮将 cookie 设置为 true 并重定向到 your-uri://
  2. 否"按钮重定向到http://itunes.com/apps/yourappname"这将在设备上打开 App Store
  3. 让我一个人呆着"按钮将 cookie 设置为 false 并关闭模态
  1. The "Yep" button sets the cookie to true and redirects to your-uri://
  2. The "Nope" button redirects to "http://itunes.com/apps/yourappname" which will open the App Store on the device
  3. The "Leave me alone" button sets the cookie to false and closes the modal

我玩过但发现有点笨拙的另一个选项是在 Javascript 中执行以下操作:

The other option I've played with but found a little clunky was to do the following in 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://";

这篇关于是否可以为 YouTube 和地图等 iPhone 应用程序注册基于 http+域的 URL 方案?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆