2016-10-07 6 views
0

私はWhatsAppを含む他のアプリと共有イメージを開発しています。 私はこのコードを使用しています。自動オープンWhatsAppは他のアプリを提示せずに直接UIDocumentINteractionControllerを使用します

if ([[UIApplication sharedApplication] canOpenURL: [NSURL URLWithString:@"whatsapp://app"]]){ 
    UIImage *image = [self processImage:sender]; 

    NSString *savePath = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/whatsAppTmp.wai"]; 

    [UIImageJPEGRepresentation(image, 1.0) writeToFile:savePath atomically:YES]; 


    _documentInteractionController = [UIDocumentInteractionController interactionControllerWithURL:[NSURL fileURLWithPath:savePath]]; 
    _documentInteractionController.delegate = self; 
    _documentInteractionController.UTI = @"net.whatsapp.image"; 
    [_documentInteractionController presentOpenInMenuFromRect:CGRectZero inView:self.view animated:YES]; 


}else { 
    [self showAlertTitle:@"WhatsApp not installed." message:@"Your device has no WhatsApp installed."]; 
} 

問題は、私はこのコードを実行すると、documentInteractionControllerこのimageのような他のオプションのアプリを提供し、私はそれオープンのWhatsAppのアプリケーションの前に最初のWhatsAppを選択しなければならない、です。

メニューを表示せずにファイルを共有するにはWhatsapp Appを選択できますか?つまり、presentOpenInMenuFromRectを避けることはできますか?私のInstagramのでもiOSの9を使用して、この問題が起こる

I`mはい

答えて

1

を投稿してください。thisコードを書くことができます。コードを実行した後、次の操作を行います。

手順:1のInfo.plist

ステップLSApplicationQueriesSchemesを追加:2項目でのWhatsAppを追加します。

+0

私はテキストデータではなく画像データを送信する必要があるので、この方法は使用できません。私が知っているように、カスタムURLスキームはまだ画像データをサポートしていません。 –

+0

@calvinsugianto編集を参照してください。 –

+0

コード内に共有拡張メソッドを実装する方法は?私はShareExtensionがdocumentInteractionControllerメソッドを参照すると思います。 –

関連する問題