WhatsApp共享无法在UIActivityViewController iOS中运行?

时间:2016-04-26 09:31:36

标签: ios xcode whatsapp

当我使用UIActiviyViewController通过什么应用程序共享链接时,它会显示一个空白的tableView?

UIActivityViewController *ACVcontroller =[[UIActivityViewController alloc]initWithActivityItems:@[text,tinyURL,append]
                                                                                      applicationActivities:nil];
[self presentViewController:ACVcontroller animated:YES completion:nil];

1 个答案:

答案 0 :(得分:0)

USe whatsapp API:http://www.whatsapp.com/faq/en/iphone/23559013

仅发送来自Objective-C的文本尝试此

NSString * msg = @"YOUR MSG To Share";
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 {
    // Cannot open whatsapp
}