Ios 如何在不打开UIActivityViewController的情况下在whatsapp上共享?

Ios 如何在不打开UIActivityViewController的情况下在whatsapp上共享?,ios,whatsapp,Ios,Whatsapp,我想直接打开whatsapp来分享视频 现在它已打开UIActivityViewController,然后我必须选择whatsapp 我不想要这个。希望它能起作用 NSString *str = @"http://r.yoz.io/PJ.c.d?";//video url str = [NSString stringWithFormat:@"%@id=%@",str]; str = [str stringByReplacingPercentEscapesUsingEncoding:NSUTF8

我想直接打开whatsapp来分享视频

现在它已打开
UIActivityViewController
,然后我必须选择whatsapp 我不想要这个。

希望它能起作用

NSString *str = @"http://r.yoz.io/PJ.c.d?";//video url

str = [NSString stringWithFormat:@"%@id=%@",str];
str = [str stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];

CFStringRef originalURLString = (__bridge CFStringRef)[NSString stringWithFormat:@"%@",str];
CFStringRef preprocessedURLString = CFURLCreateStringByReplacingPercentEscapesUsingEncoding(kCFAllocatorDefault, originalURLString, CFSTR(""), kCFStringEncodingUTF8);
NSString *urlString = (__bridge NSString*)CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault, preprocessedURLString, NULL, CFSTR("!*'();:@&=+$,/?%#[]"), kCFStringEncodingUTF8);
NSString *whatsAppURLString = [NSString stringWithFormat:@"whatsapp://send?text=%@", urlString];

if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:whatsAppURLString]])
{
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:whatsAppURLString]];
}
else
{
    UIAlertView *warningAlert = [[UIAlertView alloc] initWithTitle:@"Error" message:@"Your device has no WhatsApp installed" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
    [warningAlert show];
}