I am adding 2 crucial information NSUserActivity userInfo. But when I try to get those information on continueUserActivity, the userInfo is empty.
Here is how I am adding the info to NSUserActivity:
self.userActivity = [[NSUserActivity alloc] initWithActivityType:@"com.mysite.example"]; self.userActivity.title = rettt; self.userActivity.userInfo = @{@"subjectid" : subject.subjectId , @"subjecttype" : @"type"}; NSLog(@"userInfo %@", self.recipeUserActivity.userInfo); self.userActivity.eligibleForSearch = YES; self.userActivity.eligibleForPublicIndexing = YES; self.userActivity.webpageURL = [NSURL URLWithString:[APIHelper websiteURL:previewUrl]]; CSSearchableItemAttributeSet *attributeSet = [[CSSearchableItemAttributeSet alloc] initWithItemContentType:(NSString *)kUTTypeImage]; attributeSet.title = rettt; attributeSet.contentDescription = @"Description"; attributeSet.thumbnailData = image; attributeSet.thumbnailURL = [NSURL URLWithString:snapshotUrl]; self.userActivity.contentAttributeSet = attributeSet; [self.userActivity becomeCurrent];
Here is how I am trying to recover the information:
if ([userActivity.activityType isEqualToString:@"com.mysite.example"]){ if ([userActivity.userInfo objectForKey:@"subjecttype"] && [userActivity.userInfo objectForKey:@"subjectid"]) { //Open app page }else { return false; } }else if ([[userActivity activityType] isEqualToString:CSSearchableItemActionType]) { if ([userActivity.userInfo objectForKey:@"kCSSearchableItemActivityIdentifier"]) { //open app page } }
Do you see anything wrong with this code?
Activity type of CSSearchableItemActionType works better, since I do have at least the kCSSearchableItemActivityIdentifier, but userInfo is empty regardless.
Thanks!