Launch watch kit app from within another watch kit app

我怕爱的太早我们不能终老 提交于 2019-12-22 12:39:20

问题


I know on the phone it is possible to launch an application from within another using something along the lines of...

-(IBAction) openYoutube:(id)sender {
      UIApplication *ourApplication = [UIApplication sharedApplication];
      NSString *ourPath = @"http://www.youtube.com/watch?v=TFFkK2SmPg4";
      NSURL *ourURL = [NSURL URLWithString:ourPath];
      [ourApplication openURL:ourURL];
}

This will launch the youtube app

My research hasn't led to anything useful and I doubt there is something out there, but what's the harm in asking to be sure. Is there anyway to accomplish this sort of functionality from the apple watch? Like if the user hits a button, I want my watch kit app to launch the instagram or twitter watch kit app


回答1:


Fortunately, you can. You can ask the iOS app to do this. Use this method

[WKInterfaceController openParentApplication:@{[results firstObject]:[results firstObject]} reply:^(NSDictionary *replyInfo, NSError *error) {
    }];

To call your parent iOS app. Within the iOS app, implement this delegate method to achieve what you want (in your AppDelegate).

(void)application:(UIApplication *)application handleWatchKitExtensionRequest:(NSDictionary *)userInfo reply:(void (^)(NSDictionary *))reply{}


来源:https://stackoverflow.com/questions/29016154/launch-watch-kit-app-from-within-another-watch-kit-app

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!