如何使用 siri-kit 拨打 voip 电话 iOS10

how to make voip calls using siri-kit iOS10

我已经为应用程序添加了扩展(根据苹果文档),但意图处理程序 class 没有响应我的命令。我缺少的东西不要 no.Please 帮助我,我怎样才能将 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);
    }
}

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

  1. 指南和文档

SiriKit Programming Guide

Intents Framework

IntentsUI Framework

  1. 示例代码

UnicornChat Sample App

  1. 视频(来自 WWDC 2016)

Introducing SiriKit

Extending your app with SiriKit