我试图从我的WatchKit应用程序发送一个字符串:
我可以通过锁定屏幕启动应用程序,但是当调用continueUserActivity
方法时,userActivity.userInfo
不包含值,我在这里遗漏了什么吗?
- 我得到的唯一值是activityType
观看:
- (void)createActivity {
self.activity = [[NSUserActivity alloc] initWithActivityType:@"com.myApp.urlSend"];
[self.activity setUserInfo:@{@"url":self.wake.href}];
[self.activity setTitle:self.wake.title];
[self.activity becomeCurrent];
}
电话:
- (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void (^)(NSArray *))restorationHandler {
NSString *url = userActivity.userInfo[@"url"];
}
答案 0 :(得分:3)
我刚注意到你自己正在创建活动。如果您查看文档,您会发现Watch与其他平台相比,Handoff的工作方式略有不同:https://developer.apple.com/library/prerelease/ios/documentation/WatchKit/Reference/WKInterfaceController_class/index.html#//apple_ref/occ/instm/WKInterfaceController/updateUserActivity:userInfo:webpageURL:
您只需拨打updateUserActivity
并在该通话中添加userInfo
字典即可。