已经添加了LSApplicationQueriesScheme,我仍然收到错误消息:“不允许该应用查询方案whatsapp”

时间:2018-10-27 20:23:34

标签: swift share nsurl uiapplication

我已经检查了此问题上的其他几个问题,并为whatsapp安装了LSApplicationQueriesScheme,但是仍然不允许我的应用程序与whatsapp共享。

这是我的Info.plist文件的屏幕截图:

Here's a screenshot of my Info.plist file.

这是我分享的whatsapp代码。我希望获得一些帮助。我已经检查了其他Stack Overflow问题,但并没有帮助。

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

2 个答案:

答案 0 :(得分:1)

这是我设法解决whatssapp问题的方法:

在我的info.plist中,它是这样的: 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)
            }
        }
    }
}

答案 1 :(得分:0)

info.plist 中的错字

在您的 Info.plist 中,您忘记了“LSApplicationQueriesSchemes”末尾的“s”

错误:

LSApplicationQueriesScheme

正确:

LSApplicationQueriesSchemes