3

I'm trying to send a string from my WatchKit app: I can launch the app via the lock screen fine, but when the continueUserActivity method is called, userActivity.userInfo contains no values, am I missing something here?

-The only value I get is the activityType

Watch:

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

Phone:

- (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void (^)(NSArray *))restorationHandler {

    NSString *url = userActivity.userInfo[@"url"];
}
Halpo
  • 2,982
  • 3
  • 25
  • 54
  • Are you certain the URL is being passed as an NSString? If there's a chance it's actually an NSURL, that type isn't supported. https://developer.apple.com/library/prerelease/ios/documentation/WatchKit/Reference/WKInterfaceController_class/index.html#//apple_ref/occ/instm/WKInterfaceController/updateUserActivity:userInfo:webpageURL: – bgilham May 05 '15 at 14:29
  • @"url" is an NSString, I should've pointed that out, I'm also not getting the activity.title – Halpo May 05 '15 at 14:29

1 Answers1

3

I just noticed that you are creating the activity yourself. If you check the docs, you'll see that Handoff works a bit differently on the Watch compared to other platforms: https://developer.apple.com/library/prerelease/ios/documentation/WatchKit/Reference/WKInterfaceController_class/index.html#//apple_ref/occ/instm/WKInterfaceController/updateUserActivity:userInfo:webpageURL:

You just need to call updateUserActivity and add your userInfo dictionary in that call.

bgilham
  • 5,909
  • 1
  • 24
  • 39