Reputation: 84
In it's FAQ, WhatsApp explains how to create a new, prefilled message where the user can choose the contact to send the message to: "To create a link with just a pre-filled message" from the FAQ Page here: https://faq.whatsapp.com/iphone/how-to-link-to-whatsapp-from-a-different-app The link looks like this: https://wa.me/?text=I%27m%20inquiring%20about%20the%20apartment%20listing (example from the FAQ Page).
However, since a few days this seems not to work anymore on iOS and Desktop (Android Phones seems not to be affected yet). The link with a phone number (https://wa.me/123456789?text=The%20message%20to%20send) is working just fine. The workaround with just adding "0" as the phone number doesn't work either as whatsApp will throw an error that the contact could not be found.
Has anyone else run into the same problem? And found a soution / workaround?
Upvotes: 2
Views: 1252
Reputation: 16341
Your URL seems to be wrong. You need to append URL path which is /send
in your URL string. You seem to be adding the URLQueries right after the base URL. Also, use addingPercentEncoding
for encoding.
guard
let urlString = "whatsapp://send?text=\(text)"
.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed),
let unwrappedUrl = URL(string: urlString) else {
return nil
}
Upvotes: 0