Initiate a Siri call - stop if the contact is not in the application’s contact list

I am using a VoIP application where I need to initiate a call through Siri. I was able to initiate a call through Siri. But the problem is that every time the application starts, although the contact is not in the application’s contact list.

I am not sure how and where to do it. I mean, do not run the application if the application does not have such a contact as Skype. Skype responded with something like:

Hmm, Skype did not find.

Who do you want to call?

The following is a code snippet for an extension handler:

- (id)handlerForIntent:(INIntent *)intent { // This is the default implementation. If you want different objects to handle different intents, // you can override this and return the handler you want for that particular intent. return self; } #pragma mark - INStartAudioCallIntentHandling - (void)resolveContactsForStartAudioCall:(INStartAudioCallIntent *)intent withCompletion:(void (^)(NSArray<INPersonResolutionResult *> *resolutionResults))completion{ 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); } 

Why is this not working?

+5
source share

Source: https://habr.com/ru/post/1262197/


All Articles