我想从我的应用程序向特定的WhatsApp用户发送短信(“例如Hello World”) .
基于此whatsapp FAQ link,我可以使用自定义URL方案使用预定义文本向特定联系人号码启动whatsapp:
Question:
1) But where to get the contact ID, abid?:
2) How do I know if the contact number has whatsapp in the first place [for iOS we can't access it because of sandbox limitation right?] ?
3) How to insert the contact ID into the URL:
NSURL *whatsappURL = [NSURL URLWithString:@"whatsapp://send?text=Hello%2C%20World!"];
if ([[UIApplication sharedApplication] canOpenURL: whatsappURL]) {
[[UIApplication sharedApplication] openURL: whatsappURL];
}
1 回答
您可以改为
UIactivityViewController
,以便显示支持您文字的应用:您还可以添加图像等 .