1

I'm trying to open whatsapp conversation/chat for particular contact. Instead of opening the desired chat it only opens the app. No idea whats wrong :

 let URLString  = "whatsapp://send?abid=\(ID);text=lOL;"
        UIApplication.sharedApplication().openURL(NSURL(string: URLString)!)

URLString value : whatsapp://send?abid=414;text=lOL

Any suggestions?

Murilo
  • 1,112
  • 1
  • 18
  • 33
Roi Mulia
  • 5,626
  • 11
  • 54
  • 105

2 Answers2

3

Update your URL like this:

whatsapp://send?abid=\(ID)&text=lOL

Source from HERE.

Dharmesh Kheni
  • 71,228
  • 33
  • 160
  • 165
  • Hi, What is ID? I tried user name but it doesn't work! – Mariam Dec 29 '15 at 16:45
  • The ABID (ABRecordID) is the integer that identifies the record. You can check the doc https://developer.apple.com/library/ios/documentation/AddressBook/Reference/ABRecordRef_iPhoneOS/#//apple_ref/c/tdef/ABRecordID – andreacipriani Mar 31 '16 at 09:10
  • I tried it in iOS 9.3.1 and it doesn't work. The whatsapp show me the Select Contact panel. Anyone had the same problem? – dcorbatta Apr 15 '16 at 21:42
  • 1
    @dcorbatta I have same problem. But no solutions for now :( – rabbitinspace Apr 19 '16 at 16:15
  • 1
    @dcorbatta I have same problem. Found no info about it till now. – Apple.CDM May 08 '16 at 20:12
  • We have to try to contact with Whatsapp. What is the dev support email? – dcorbatta May 09 '16 at 22:07
  • It no longer works on iOS 9.0.2 I think WhatsApp killed the functionality, we need to contact the dev support team and find out if it was on purpose !. – Wael Jul 20 '16 at 11:05
  • I sent them a question and waiting a response, the following used to work and it stopped with the most recent update: [[UIApplication sharedApplication] openURL: [NSURL URLWithString:[NSString stringWithFormat:@"whatsapp://send?abid=%d&text=%@", abid, @""]]]; – Wael Jul 20 '16 at 11:18
  • WhatsApp could have renamed abid into something else or completely got rid of it. ! – Wael Jul 21 '16 at 23:10
  • @Will Do you have news? – dcorbatta Sep 16 '16 at 17:50
  • Hi, Yes I am not sure what was wrong but there is nothing wrong with WhatsApp, it was only resolved after a restore, or it started working again by itself. It was a really crazy situation. ! – Wael Oct 02 '16 at 23:13
1

Try this and check if the UIApplication and open the URL.

let whatsAppURL: NSURL = NSURL(string: "whatsapp://send?abid=\(ID)&text=lOL")
if UIApplication.sharedApplication().canOpenURL(whatsAppURL){
    UIApplication.sharedApplication().openURL(whatsAppURL)
}
Brian Nezhad
  • 6,148
  • 9
  • 44
  • 69