Open WhatsApp conversation using Abid doesn't

2019-08-08 07:33发布

问题:

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?

回答1:

Update your URL like this:

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

Source from HERE.



回答2:

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)
}