【发布时间】:2016-08-27 15:47:40
【问题描述】:
测试背景: Xcode:Xcode8 beta6 iPhone:iOS10 beta6 语言:object-c
我在我的应用程序中使用了 startAudioCall sirikit 来测试我的应用程序调用。但是,sirikit 在某些情况下会失败: 如果这个人的名字是本地联系人中的名字,当我说“Call firstname myApp”时,siri可以启动myApp成功获取这个联系人姓名 但是如果这个人的名字既是名字又是姓氏,当我说 "Call firstname(or both first name and last name) myApp" 时,siri 会用电话呼叫这个人(不是 myApp)
例如: 如果 John 在我的电话联系人中,我说“呼叫 John myApp”,这将启动 myApp 并成功获取此联系人姓名。 但是如果 John Smith 在我的电话中联系,并且我说 "call John(or John Smith) myApp" ,siri 将使用电话呼叫这个人(不是 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);
}
这是我关于音频通话的代码。 任何人都可以帮忙吗?非常感谢
【问题讨论】:
-
所以当你说“打电话给 John myApp”并且 siri 使用手机而不是你的应用时,你的 resolveContactsForStartAudioCall 方法被调用了吗?
-
不,resolveContactsForStartAudioCall这个函数不会来,所以,我不知道如何控制这种情况。