Apple Watch:在 iPhone 设备上的 Apple Watch 打开 URL 上点击按钮
AppleWatch : On button tap from the the AppleWach Open URL on iPhone device
我想打开 url 从 Apple Watch 应用程序按钮点击到移动应用程序。
请问有人对这些有任何想法吗?
已将此添加到您的 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
中的按钮 tap
上应用的内容
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]});
}
我想打开 url 从 Apple Watch 应用程序按钮点击到移动应用程序。 请问有人对这些有任何想法吗?
已将此添加到您的 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
中的按钮tap
上应用的内容
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]});
}