Have already added LSApplicationQueriesScheme and I still get error: "This app is not allowed to query for scheme whatsapp"

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:

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

Answers (2)

J.K.
J.K.

Reputation: 303

Typo in info.plist

In your Info.plist you forgot the "s" at the end of "LSApplicationQueriesSchemes"

Wrong:

LSApplicationQueriesScheme

Correct:

LSApplicationQueriesSchemes

Upvotes: 1

This is how I managed to solve the whatssapp issue:

In my info.plist this is how it looks: enter image description here

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

Related Questions