无法从今天的分机

时间:2017-05-24 10:02:05

标签: ios swift

我已经为我的应用小部件添加了一个按钮。在阅读了一些手册和SO建议后,我已经实现了他们所写的内容,但我的行动并没有打开主机应用程序。 Here's how I made in Info.plist of host app

我使URL标识符完全像包标识符(com.ol.MyList)和com.ol.两者都没有用。

这是我的行动:

@IBAction func openHostApp() {
    if let url = URL(string: "localHost") {
        self.extensionContext?.open(url, completionHandler: {success in print("called url complete handler: \(success)")})
    }
}

它已经编译并且没有崩溃,但是completionHandler总是返回' false'为了成功'参数。我做错了什么以及如何做对了?

我还想添加另一个按钮来打开主机应用并在那里执行操作。如何实施该案例?

1 个答案:

答案 0 :(得分:6)

今日扩展程序

打开主机应用程序

1.添加URL SchemelocalHost来托管应用URL Types

use gulp to clean the output directory

2.编码从host app打开extension

   @IBAction func openHostApp()
{
    if let url = URL(string: "localHost://")
    {
        self.extensionContext?.open(url, completionHandler: {success in print("called url complete handler: \(success)")})
    }
}