Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
293 views
in Technique[技术] by (71.8m points)

ios - Launch host app from watch app

I know that the openParentApplication api in watch kit extension can open the host app in the background but not in the foreground.

I also tried using openUrl() api of NSExtensionContext as below:

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];

Here too the host app is not launched. Am I missing something? or is it not possible to launch the host app from watch kit extension?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

As of Beta 3 of iOS 8.2 it is currently not possible to open iOS app to foreground. As you said openParentApplication can open app in background. Unfortunately there is no sign of API to open app on iPhone.

Multiple posts on Apple Dev Forums mentioned that it's not possible

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.

And other post

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

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

56.9k users

...