Open whatsapp on iOS with a new phone number pre-populated

I know that there is a scheme for communicating with whatsapp:

NSURL *whatsappURL = [NSURL URLWithString:@"whatsapp://send?text=Hello%2C%20World!"]; if ([[UIApplication sharedApplication] canOpenURL: whatsappURL]) { [[UIApplication sharedApplication] openURL: whatsappURL]; } 

But I can not find how to open whatsapp with a phone number that was not there before.

This is for the contatc us page, and if I can only open whatsapp and cannot prefill the phone number, it is useless. I need to contact whatsapp ...

Is there something I'm trying to do?

+5
source share
5 answers

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 swift

Check the link for more details https://www.whatsapp.com/faq/en/general/26000030

+6
source

According to the Whatsapp documentation , you should really have a contact in your address book in order to open a discussion from a URL scheme. <w> therefore for your question

Is what I'm trying to do exist?

answer: no

enter image description here

+1
source

You can find documentation on this whatsapp API above answer. Adding a few more points to that based on my own trial version:

For direct communication with a specific contact you need to follow this contact. ABID is the parameter that is automatically generated by the system when a contact is saved. Therefore, if you do not have a number stored in your contact, so you cannot open it from your application.

There is one workaround that I used. When your application is first downloaded to the device, you save the contact number in the address book. when the number is saved successfully, you will get the ABID in the opposite direction. You can use this ABID to call messaging with this contact.

 NSURL *whatsappURL = [NSURL URLWithString:@"whatsapp://send?abid=123&text=Hello%2C%20World!"]; 
+1
source

If someone is looking for a version of Swift

 static func triggerWhats(_ vc:UIViewController){ let msg = "Hello! I have a question" let urlWhats = "whatsapp://send?phone=+6599999999&text=\(msg)" if let urlString = urlWhats.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed){ if let whatsappURL = NSURL(string: urlString) { if UIApplication.shared.canOpenURL(whatsappURL as URL) { _ = UIApplication.shared.open(whatsappURL as URL, options: [:], completionHandler: nil) } else { // Cannot open whatsapp ViewUtil().popAlertView(vc, title: "WhatsApp Support", message: "Please WhatsApp us at +65999999 if you have any questions", option: "Ok") } } } } 
+1
source

Swift 3.0 open the Whats app.

in the info.plist file add this line

 <key>LSApplicationQueriesSchemes</key> <array> <string>whatsapp://</string> </array> func OpenWhatsApp(_ vc:UIViewController){ let msg = "" // here pass your message let urlWhats = "https://api.whatsapp.com/send?phone=(Mobileno)&text=\(msg)" // Mobile number that include country code and without + sign . if let urlString = urlWhats.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed){ if let whatsappURL = URL(string: urlString) { if UIApplication.shared.canOpenURL(whatsappURL) { if #available(iOS 10.0, *) { _ = UIApplication.shared.open(whatsappURL, options: [:], completionHandler: nil) } else { // Fallback on earlier versions UIApplication.shared.canOpenURL(whatsappURL) } } else { // Cannot open whatsapp AppUtilities.sharedInstance.showAlert(title: "WhatsApp Support", msg: "Your device is not support whats app") } } } } 
+1
source

All Articles