【发布时间】:2016-04-17 15:12:56
【问题描述】:
我想在同一部手机上安装的两个应用程序之间进行通信。为了做到这一点,我阅读了很多官方文档,了解到我必须实现一个Custom URL Scheme。
在iOS 9之前,好像我们得在Info中加个URLType 并定义 URL Scheme : " "。
但在 iOS 9 之后,它改变了 App 之间的通信方式。
url 方案示例在:Querying URL Schemes with canOpenURL 中讨论。
我的应用代码如下:
@IBAction func sender(sender: AnyObject) {
let ourapplication : UIApplication = UIApplication.sharedApplication()
let ourpath : String = "iOSTest://"
//.stringByAppendingString(urlEncodedText)
let oururl : NSURL = NSURL(string: ourpath)!
ourapplication.canOpenURL(oururl)
}
在我的 App B 中,我在 Info.plist 中添加了一个 URL 名称 iOSTest
<key>LSApplicationQueriesSchemes</key>
<array>
<string>iOSTest</string>
</array>
当我在我的 iPhone 上安装这两个 App 进行测试时,它根本不起作用。
这是我的错误!
我的应用有什么问题?
【问题讨论】:
标签: ios swift url-scheme openurl