Reputation: 522
I have already checked several of the other questions on this matter, and installed the LSApplicationQueriesScheme
for whatsapp, but my application still is not being allowed to share with whatsapp.
Here's a screenshot of my Info.plist
file:
This is my sharing whatsapp code. I would love for some help. I have already checked the other Stack Overflow questions and they haven't helped.
@IBAction func shareWhattsappButtonTapped(_ sender: UIButton) {
let shareMessage = "Hola! Estoy buscando a mi \(posts!.petType) que es de raza \(posts!.breed). La ultima vez que lo vimos fue en \(posts?.address). Ayudenme a encontrarlo porfavor! Subi la foto con toda la información a Gastet. Pueden verlo aquí: https://itunes.apple.com/mx/app/gastet/id1407059324?l=en&mt=8"
shareWhatssapp(message: shareMessage)
}
func shareWhatssapp(message: String) {
let msg = message
let urlWhats = "whatsapp://send?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)
}
}
}
}
Upvotes: 2
Views: 4607
Reputation: 303
In your Info.plist you forgot the "s" at the end of "LSApplicationQueriesSchemes"
LSApplicationQueriesScheme
LSApplicationQueriesSchemes
Upvotes: 1
Reputation: 522
This is how I managed to solve the whatssapp issue:
In my info.plist this is how it looks:
func shareWhatssapp(message: String) {
let msg = message
let urlWhats = "whatsapp://send?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)
}
}
}
}
Upvotes: 4