简体   繁体   English

无法从今天的分机上打开主机应用程序

[英]Can't open host app from today extension

I've aded a button to my app widget. 我已经为我的app小部件添加了一个按钮。 After reading some manuals and SO advises I've implemented what they wrote, but my action doesn't open host app. 在阅读了一些手册和SO建议后,我已经实现了他们所写的内容,但我的操作并未打开主机应用程序。 Here's how I made in Info.plist of host app 这是我在主机应用的Info.plist中所做的

And I made URL identifier both completely like the bundle identifier (com.ol.MyList) and just com.ol. 我使URL标识符完全像包标识符(com.ol.MyList)和com.ol. Both didn't work. 两者都没用。

And here's my action: 这是我的行动:

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

It's compiled and doesn't crash, but completionHandler always return 'false' for 'success' parameter. 它已编译且不会崩溃,但completionHandler始终为'success'参数返回'false'。 What I made wrong and how to make it right? 我犯了什么错,怎么做对了?

I also want to add another button that opens host app and performs an action in there. 我还想添加另一个按钮,打开主机应用程序并在那里执行操作。 How to implement that case? 如何实施那个案子?

To open host app from Today Extension : Today Extension打开主机应用程序

1.Add URL Scheme : localHost to host app's URL Types . 1.添加URL SchemelocalHost来托管应用程序的URL Types

在此输入图像描述

2.Code to open host app from extension , 2.Code从extension host app打开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)")})
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 打开包含今日扩展的应用程序时崩溃 - Crash when open containing app from today extension 从我的应用程序中的“今日扩展”(窗口小部件)打开Safari - Open Safari from my Today Extension (widget) within my app 来自Today Extension的打开网址 - Open url from Today Extension 无法在应用程序和今日扩展之间共享数据 - Can't share data between app and today extension 从 Widget 打开宿主应用程序时未调用 AppDelegate 函数(今日扩展) - AppDelegate function not called when open the host application from the Widget (Today Extension) 从今日扩展(小部件)在主机应用程序中执行操作,无需打开应用程序ios - Perform action in host app from Today extension(Widget) Without opening app ios 如何使用主机应用程序中的数据更新iOS 10 Today小部件扩展? - How to update iOS 10 today widget extension with data from host app? 当主应用程序未打开时,Swift 如何从今天的扩展中打开特定的视图控制器 - Swift how to open specific viewcontroller from today extension when main app is not open 今天扩展开始时,主机应用程序中是否调用了某种方法? - Is some method called in the host app when today extension starts? 如何使用Swift在我的应用程序的“今日扩展”中的Safari中打开url - How to open a url in Safari from my Today Extension within my app using Swift
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM