0

I tried below code to set and get NSUserActivity but it does not work for me. I am not able to get the data for nsuseractivity I am testing below code in device with iOS version 10 and above. Set NSUserActivity in callkit:

NSUserActivity *activity = [[NSUserActivity alloc] initWithActivityType:@"INStartAudioCallIntent"];
    activity.title = @"title";
    activity.delegate = self;
    activity.needsSave = YES;
    activity.webpageURL = [NSURL URLWithString:@"https://www.google.com"];
    activity.userInfo = @{@"name": @"test", @"deep_link": @"test"};
    // set requiredUserInfoKeys if you're also setting webPageURL !!
    // otherwise, userInfo will be nil !!
   activity.requiredUserInfoKeys = [NSSet setWithArray:@[@"name", @"deep_link"]];
    activity.eligibleForSearch = YES;
    activity.eligibleForPublicIndexing = YES;
    [activity becomeCurrent];


- (void)userActivityWillSave:(NSUserActivity *)userActivity {
    userActivity.userInfo = @{@"name": @"test", @"deep_link": @"test"};
    NSLog(@"userActivityWillSave");
}

- (void)updateUserActivityState:(NSUserActivity *)userActivity {
    NSLog(@"updateUserActivityState");
    [userActivity addUserInfoEntriesFromDictionary:@{@"name": @"test", @"deep_link": @"test"}];
}

in info.plist : NSUserActivityTypes as INStartAudioCallIntent INStartAudioCallIntent

in Appdelegate.m :

- (BOOL)application:(UIApplication *)application
continueUserActivity:(NSUserActivity *)userActivity
 restorationHandler:(void (^)(NSArray<id<UIUserActivityRestoring>> *restorableObjects))restorationHandler{
     NSLog(@" Userinfo Data==>%@  useractivityTitle ==>%@  activityType-->%@ webpage-->%@",userActivity.userInfo , userActivity.title,userActivity.activityType,userActivity.webpageURL );
    return YES;
}

Note : I checked the code for Speakerbox.

ios developer
  • 3,363
  • 3
  • 51
  • 111
  • 1
    Did you figure this out? – Viktor Gardart Jan 28 '19 at 10:27
  • @ViktorGardart Yes we don't need to set the nsuseractivity for startAudioCallIntent. I just have to make sure update.remoteHandle = [[CXHandle alloc] initWithType:CXHandleTypeGeneric value:ContactID]; and providerConfiguration.supportedHandleTypes = [NSSet setWithObjects:[NSNumber numberWithInteger:CXHandleTypeGeneric],[NSNumber numberWithInteger:CXHandleTypePhoneNumber], nil]; in my callkit and it works fine – ios developer Jan 28 '19 at 15:19

0 Answers0