Test example: Xcode: Xcode8 beta6 iPhone: iOS10 beta6 Language: object-c
I used startAudioCall sirikit in my application to test my application call. However, it will fail in some situation: If the person’s name is the first name in the local contact, when I say “Call firstname myApp”, siri can run myApp to get this contact name successfully But if the person’s name is both a name and by last name, when I say "Call name (or first and last name) myApp", siri will call this person with a phone call (not myApp)
For example: if John contacts my phone and I say “call John myApp”, this will start myApp and get this contact name successfully. But if John Smith contacts my phone and I say “call John (or John Smith) myApp,” Siri will use a phone call to call that person (not myApp)
- (void)resolveContactsForStartAudioCall:(INStartAudioCallIntent *)intent withCompletion:(void (^)(NSArray<INPersonResolutionResult *> *resolutionResults))completion{ NSLog(@"maytest resolveContactsForStartAudioCall"); NSArray<INPerson *> *recipients = intent.contacts; NSMutableArray<INPersonResolutionResult *> *resolutionResults = [NSMutableArray array]; if (recipients.count == 0) { completion(@[[INPersonResolutionResult needsValue]]); return; }else if(recipients.count==1){ [resolutionResults addObject:[INPersonResolutionResult successWithResolvedPerson:recipients.firstObject]]; }else if(recipients.count>1){ [resolutionResults addObject:[INPersonResolutionResult disambiguationWithPeopleToDisambiguate:recipients]]; }else{ [resolutionResults addObject:[INPersonResolutionResult unsupported]]; } completion(resolutionResults); } - (void)confirmStartAudioCall:(INStartAudioCallIntent *)intent completion:(void (^)(INStartAudioCallIntentResponse *response))completion{ NSUserActivity *userActivity = [[NSUserActivity alloc] initWithActivityType:NSStringFromClass([INStartAudioCallIntent class])]; INStartAudioCallIntentResponse *response = [[INStartAudioCallIntentResponse alloc] initWithCode:INStartAudioCallIntentResponseCodeReady userActivity:userActivity]; completion(response); } - (void)handleStartAudioCall:(INStartAudioCallIntent *)intent completion:(void (^)(INStartAudioCallIntentResponse *response))completion{ NSUserActivity *userActivity = [[NSUserActivity alloc] initWithActivityType:NSStringFromClass([INStartAudioCallIntent class])]; INStartAudioCallIntentResponse *response = [[INStartAudioCallIntentResponse alloc] initWithCode:INStartAudioCallIntentResponseCodeContinueInApp userActivity:userActivity]; completion(response); }
And here is my audiocall code. Can anybody help? thanks a lot
source share