点击网址iOS时打开应用 [英] Open an app when clicking on a url iOS

查看:129
本文介绍了点击网址iOS时打开应用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道在iOS中单击safari(或其他浏览器)中的链接时是否有办法打开应用程序。

I'm wondering if there is a way to open an app when clicking on a link in safari (or other browser) in iOS.

我的应用程序发布了一个位置的名称,Twitter / Facebook上的截图,也有一个链接。我需要检测用户何时点击该链接,如果他在PC或iOS设备上。如果他们不在iOS设备上,我想继续链接页面,否则我想打开应用程序,并在打开时将该位置名称作为参数。

My app posts the name of a location, a screenshot on Twitter/Facebook which also has a link. I need to detect when the user clicks that link if he is on a pc or iOS device. If they're not on iOS device I want to continue to the linked page otherwise I want to open the app and also take take that location name as a parameter when opening it.

推荐答案

如果应用程序已注册自定义URL方案,则当设备要求打开特定方案的URL时,设备将打开该特定应用程序。

If the app has registered a custom URL scheme the device will open the particular app when it's asked to open a URL of a particular scheme.

这源于您的应用infoPlist的 CFBundleURLSchemes 键。 Apple的文档包含开始所需的所有信息。

This stems from the CFBundleURLSchemes key of your apps infoPlist. Apple's documentation has all the information you need to get started.


要为您的应用注册URL类型,请包含CFBundleURLTypes键
在你的应用程序的Info.plist文件中。 CFBundleURLTypes键包含
字典数组,每个字典都定义app
支持的URL方案。表6-2描述了每个
字典中包含的键和值。

To register a URL type for your app, include the CFBundleURLTypes key in your app’s Info.plist file. The CFBundleURLTypes key contains an array of dictionaries, each of which defines a URL scheme the app supports. Table 6-2 describes the keys and values to include in each dictionary.

iOS编程指南:高级应用技巧下的'与其他应用程序部分进行通信。

See more here at the iOS Programming Guide: Advanced App Tricks under 'Communicating with Other Apps' section.

为了支持特定的您需要更深入一些问题的功能。

In order to support the specific functionality of your question you need to go one step deeper.


  1. 您的第一个链接需要是标准的网址。

  2. 从第一个URL显示的页面需要检测设备并将用户转发到第二个URL,该URL将打开设备上的应用程序,无论您要将哪个参数转发到应用程序。

所以 - 您将要做的是在您的页面中构建某种设备检测第一个URL指向。在该页面上,检测设备,然后有条件地将用户转发到将作为特定应用程序的自定义URL的第二个URL。

So - what you're going to have to do is build some sort of device detection into the page that your first URL points to. On that page, detect the device, then conditionally forward the user onto the second URL that will be the custom URL of your particular app.

可以执行此设备检测,并检测他们的设备上是否安装了应用程序以及移动浏览器支持的一些较新的HTML5功能,但您的问题主题是在iOS中打开带有URL的应用程序以及支持打开应用程序所需的主要原生iOS挂钩(带有参数和所有)在上面的文档中。

It's possible to do this device detection, and detect if they have the app installed on their device with some of the newer HTML5 features supported by mobile browsers, but your question is themed around opening apps with URLs in iOS and the main native iOS hooks you need to support opening apps (with parameters and all) is in the documentation above.

这篇关于点击网址iOS时打开应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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