【发布时间】:2015-10-02 12:47:59
【问题描述】:
我正在尝试通过 WhatsApp 共享文本 + url,但没有在 WhatsApp 文本字段中填充任何内容。
我尝试了以下代码:
NSString *urlString = [NSString stringWithFormat:@"http://www.mouthshut.com/contest?ref=%@&inv_via=whatsapp&act=reg", UserName];
//NSURL *url = [NSURL URLWithString:urlString];
//urlString = [urlString stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSString * urlWhats = [NSString stringWithFormat:@"whatsapp://send?text=Writing a review is better than whatsapp. Win cash prizes daily on MouthShut.com \n Join Now %@", urlString];
NSURL * whatsappURL = [NSURL URLWithString:[urlWhats stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
if ([[UIApplication sharedApplication] canOpenURL: whatsappURL]) {
[[UIApplication sharedApplication] openURL: whatsappURL];
} else {
UIAlertView * alert = [[UIAlertView alloc] initWithTitle:@"Alert!" message:@"Your device has no WhatsApp installed." delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert show];
}
【问题讨论】:
-
我可以知道为什么这个问题被否决了吗?
标签: ios text ios8 share whatsapp