I know there is scheme to communicate with whatsapp like:
NSURL *whatsappURL = [NSURL URLWithString:@"whatsapp://send?text=Hello%2C%20World!"];
if ([[UIApplication sharedApplication] canOpenURL: whatsappURL]) {
[[UIApplication sharedApplication] openURL: whatsappURL];
}
But i can't find how to open whatsapp with a phone number that don't exist before.
It's for a "contatc us" page and if i can only open whatsapp and can't pre fill a phone number, it's useless. I need to be contacted with whatsapp...
Does what I am trying to do exist ?
For phone number pre-filled And Text
NSURL *whatsappURL = [NSURL URLWithString:@"https://api.whatsapp.com/send?phone=9530670491&text=hello"];
if ([[UIApplication sharedApplication] canOpenURL: whatsappURL]) {
[[UIApplication sharedApplication] openURL: whatsappURL];
}
click here for Swift
Check Link For More Details https://www.whatsapp.com/faq/en/general/26000030
According to the Whatsapp documentation, you need to actually have the contact in your address book to open a discussion from the url scheme.
So for your question
Does what i try to do exist ?
the answer is: No.
You can find the documentation of that whatsapp API above answer. Adding some more point in that based on my own trial :
For communicating direct with the specific contact you need abid of that contact. ABID is that parameter which is automatically generated by the system when you save the contact. So if you dont have number saved in your contact so no way you can open that from your application .
There is one workaround that I have used. When your application load first time in the device , you save the contact us number to the address book . when number saved successfully you will get ABID in the return . you can use that ABID to invoke messaging with that contact.
NSURL *whatsappURL = [NSURL URLWithString:@"whatsapp://send?abid=123&text=Hello%2C%20World!"];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With