[英]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 Scheme
: localHost
来托管应用程序的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.