0

我已经向应用程序添加了扩展(根据苹果文档),但意图处理程序类没有响应我的命令。我想念的不是。请帮助我,如何将 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);
    }
}
4

1 回答 1

1

这里有一些资源可以帮助您入门。

  1. 指南和文档

SiriKit 编程指南

意图框架

IntentsUI 框架

  1. 示例代码

UnicornChat 示例应用程序

  1. 视频(来自 WWDC 2016)

介绍 SiriKit

使用 SiriKit 扩展您的应用程序

于 2016-07-11T14:36:14.320 回答