2017-01-04 5 views
-26

私はSiriを通じて通話を開始する必要のあるVoIPアプリケーションを実装しています。私はSiriを通じて電話をかけることができました。しかし、問題は、連絡先がアプリケーションの連絡先リストにないのに、アプリケーションが起動されるたびに問題です。Siri - 音声通話のskypeに似た連絡先検索の動作

どうやってそれを処理するかわかりません。アプリケーションがSkypeのようにその連絡先を持っていない場合は、アプリケーションを起動しないことを意味します。

うん、スカイプは<ユーザーを見つけませんでした。

誰に電話しますか?

ベローは、拡張ハンドラのための私のコードスニペットです:

- (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); 
} 
+10

(http://meta.stackoverflow.com/questions/340839/user-answers-a-question-of -another-user-and-asks-the-same-questions-again-already?cb = 1)のようになります。私はdownvotingを止めることができると思う。 –

+0

@ThomasWellerご返信ありがとうございます。私はメタ・ディスカッションでそれを明確にしようとしました。間違いは私のものでした。私はそれについて謝罪しました。まだダウン投票しています。 – makboney

答えて

2

あなたはあなたがその意思に入る人はアプリの連絡先リストに含まれていることを確認し、resolveContactsForStartAudioCall方法でそれを処理することができます。

- (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){ 
      if([self containContact:recipients.firstObject.displayName]){ 
       [resolutionResults addObject:[INPersonResolutionResult successWithResolvedPerson:recipients.firstObject]]; 
      }else [resolutionResults addObject:[INPersonResolutionResult unsupported]]; 
     }else if(recipients.count>1){ 
      [resolutionResults addObject:[INPersonResolutionResult disambiguationWithPeopleToDisambiguate:recipients]]; 
     }else{ 
      [resolutionResults addObject:[INPersonResolutionResult unsupported]]; 
     } 
     completion(resolutionResults); 
} 
- (BOOL)containContact:(NSString *)displayName { 
      //fetch contacts and check, if exist retun YES else NO 
} 

アプリケーションの連絡先を任意の拡張子に共有する場合は、アプリケーショングループサポートを有効にする必要があります。ここではいくつかのガイドラインがあります:[メタ上]話題

  1. Apple Document
  2. Stack Overflow link
関連する問題