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

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

问题描述

我想让iOS从我的域名中打开网址(例如 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)检查用户代理,如果是移动Safari,请打开myprotocol:// URL以(尝试)打开iPhone应用程序并打开移动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. Nope按钮重定向到 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应用程序(如YouTube和地图)注册基于http +域的URL方案?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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