我正在使用以下代码从我的iOS应用程序分享文本到WhatsApp。
NSString *textToSend = [NSString stringWithFormat:@"whatsapp://send?text=%@", self.theTextView.text];
NSURL *whatsappURL = [NSURL URLWithString:textToSend];
if ([[UIApplication sharedApplication] canOpenURL: whatsappURL]) {
[[UIApplication sharedApplication] openURL: whatsappURL];
}else{
[[[UIAlertView alloc] initWithTitle:nil message:@"Whatsapp not isntalled on this device! Please install first." delegate:nil cancelButtonTitle:@"Okay" otherButtonTitles:nil, nil]show];
}
这并不按照预期工作。
如果我像这里所解释的那样做,它可以正常工作。
NSURL *whatsappURL = [NSURL URLWithString:@"whatsapp://send?text=Hello%2C%20World!"];