Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/115.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
无需菜单ios自动共享到whatsapp_Ios_Audio_Share_Whatsapp - Fatal编程技术网

无需菜单ios自动共享到whatsapp

无需菜单ios自动共享到whatsapp,ios,audio,share,whatsapp,Ios,Audio,Share,Whatsapp,我有一个声音,我想在Whatsapp上分享,使用UIDocumentInteractionController它工作得很好,但我不想让用户选择Whatsapp,我希望它立即被选中。可能吗 对于文本共享,它可以按照我的要求工作,它会立即使用深度链接打开Whatsapp whatsapp://send?text=test 我不希望在共享声音时显示此菜单: 对于文本: NSString * msg = @"Your Text"; NSString * urlWhats = [NSString str

我有一个声音,我想在Whatsapp上分享,使用UIDocumentInteractionController它工作得很好,但我不想让用户选择Whatsapp,我希望它立即被选中。可能吗

对于文本共享,它可以按照我的要求工作,它会立即使用深度链接打开Whatsapp

whatsapp://send?text=test
我不希望在共享声音时显示此菜单: 对于文本:

NSString * msg = @"Your Text";
NSString * urlWhats = [NSString stringWithFormat:@"whatsapp://send?text=%@",msg];

NSURL * whatsappURL = [NSURL URLWithString:[urlWhats stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];

if ([[UIApplication sharedApplication] canOpenURL: whatsappURL]) {
    [[UIApplication sharedApplication] openURL: whatsappURL];

}

else{

UIAlertView * alert = [[UIAlertView alloc] initWithTitle:@"WhatsApp not installed." message:@"Your device has no WhatsApp installed." delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
    [alert show];

}
对于图像:

.h文件:

<UIDocumentInteractionControllerDelegate>

@property (retain) UIDocumentInteractionController * documentInteractionController;

我已经这么做了,我不想在你打电话给PresentOpenMinumeFromRect时给他们看菜单,我想马上挑选Whatsapp。我也一直在尝试这样做。你运气好吗?
    if ([[UIApplication sharedApplication] canOpenURL: [NSURL URLWithString:@"whatsapp://app"]]){

        UIImage     * iconImage = [UIImage imageNamed:@"YOUR IMAGE"];
        NSString    * savePath  = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/whatsAppTmp.wai"];

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

        _documentInteractionController = [UIDocumentInteractionController interactionControllerWithURL:[NSURL fileURLWithPath:savePath]];
        _documentInteractionController.UTI = @"net.whatsapp.image";
        _documentInteractionController.delegate = self;

        [_documentInteractionController presentOpenInMenuFromRect:CGRectMake(0, 0, 0, 0) inView:self.view animated: YES];


    } else  {

        UIAlertView * alert = [[UIAlertView alloc] initWithTitle:@"WhatsApp not installed." message:@"Your device has no WhatsApp installed." delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
        [alert show];
 }