gpt4 book ai didi

ios - 从 watch 应用程序启动主机应用程序

转载 作者:技术小花猫 更新时间:2023-10-29 10:29:46 24 4
gpt4 key购买 nike

我知道 watch kit 扩展中的 openParentApplication api 可以在后台打开主机应用程序,但不能在前台打开。

我还尝试使用 NSExtensionContextopenUrl() api,如下所示:

NSExtensionContext *ctx = [[NSExtensionContext alloc] init];

NSURL *url = [NSURL URLWithString:@"myScheme://today"];
[ctx openURL:url completionHandler:^(BOOL success) {
NSLog(@"fun=%s after completion. success=%d", __func__, success);
}];
[ctx completeRequestReturningItems:ctx.inputItems completionHandler:nil];

这里也没有启动主机应用程序。我错过了什么吗?还是不可能从 watch 套件扩展启动主机应用程序?

最佳答案

从 iOS 8.2 的 Beta 3 开始,目前无法将 iOS 应用程序打开到前台。正如您所说,openParentApplication 可以在后台打开应用程序。不幸的是,没有迹象表明可以在 iPhone 上打开应用程序的 API。

Apple Dev Forums 上的多篇帖子都提到这是不可能的

https://devforums.apple.com/message/1076125#1076125

Correct, a notification can still declare a background action that the iPhone app will handle, so in that sense it can launch the iPhone app. But the iPhone app cannot be brought to the foreground by a WatchKit app.

和其他帖子

https://devforums.apple.com/message/1082620#1082620

On a device, it[Watch app] will not - bring your iOS app to the foreground.

关于ios - 从 watch 应用程序启动主机应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27700907/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com