AppleWatch:从iPhone设备上的AppleWatch打开URL点击按钮

AppleWatch:从iPhone设备上的AppleWatch打开URL点击按钮,iphone,apple-watch,Iphone,Apple Watch,我想打开从AppleWatch应用程序按钮点击到移动应用程序的url。 请问有人对这些有什么想法吗 将此添加到您的AppDelegate.m中 - (void)application:(UIApplication *)application handleWatchKitExtensionRequest:(NSDictionary *)userInfo reply:(void(^)(NSDictionary *replyInfo))reply { [[UIApplication shar

我想打开从AppleWatch应用程序按钮点击到移动应用程序的url。
请问有人对这些有什么想法吗

将此添加到您的AppDelegate.m中

- (void)application:(UIApplication *)application handleWatchKitExtensionRequest:(NSDictionary *)userInfo reply:(void(^)(NSDictionary *replyInfo))reply 
{
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://www.google.com"]];
}

这是您必须在Watch App中的按钮
点击
时应用的内容

NSURL *url = // your URL
NSDictionary *dic = [[NSDictionary alloc] initWithObjectsAndKeys:url, @"URLKey", nil];
[WKInterfaceController openParentApplication:dic reply:^(NSDictionary *replyInfo, NSError *error)
 {
  NSLog(@"%@ %@",replyInfo, error);
 }];
您可以在iPhone中的
AppDelegate.m

- (void)application:(UIApplication *)application handleWatchKitExtensionRequest:(NSDictionary *)userInfo reply:(void(^)(NSDictionary *replyInfo))reply
{
    //receive userinfo dictionary here to perform specific request from watch
    NSString *url = [userInfo objectForKey:@"URLKey"];
    // perform operation on url
    reply(@{@"Notification Alert":[NSString stringWithFormat:@"%f",dist]});
}