我已经向应用程序添加了扩展(根据苹果文档),但意图处理程序类没有响应我的命令。我想念的不是。请帮助我,如何将 siri 添加到我的应用程序中。
// reslove
- (void)resolveContactsForStartAudioCall:(INStartAudioCallIntent *)intent
withCompletion:(void (^)(NSArray<INPersonResolutionResult *> *resolutionResults))completion{
NSArray *contacts;
NSArray * contacts1;
INPersonResolutionResult* result = nil;
if (contacts == intent.contacts) {
for (INPerson *contact in contacts) {
contacts1 = [self contactsMatchingName:contact.displayName];
switch (contacts1.count) {
case 1:
result = [contacts objectAtIndex:0];
[INPersonResolutionResult successWithResolvedPerson:[contacts1 objectAtIndex:0]];
break;
case 0:
result = [INPersonResolutionResult unsupported];
break;
default:
result = [ INPersonResolutionResult disambiguationWithPeopleToDisambiguate:contacts1];
break;
}
}
completion(contacts1);
}else{
result = [INPersonResolutionResult needsValue];
}
}
// confirmation method
- (void)confirmStartAudioCall:(INStartAudioCallIntent *)intent
completion:(void (^)(INStartAudioCallIntentResponse *response))completion{
INStartAudioCallIntentResponse *result = nil;
if (![[NSUserDefaults standardUserDefaults]objectForKey:@"isSignedIn"]) {
result = [[INStartAudioCallIntentResponse alloc]initWithCode:INStartAudioCallIntentResponseCodeReady userActivity:nil];
completion(result);
}else{
NSUserActivity *activity = [[NSUserActivity alloc]initWithActivityType:@"reLogin"];
result = [[INStartAudioCallIntentResponse alloc]initWithCode:INStartAudioCallIntentResponseCodeFailure userActivity:activity];
completion(result);
}
}