来自 iOS 应用程序的 Viber 重定向

问题描述

我将尝试打开 viber 表单单击我的应用程序按钮操作

let phoneNumber = "7878745015"
        let viberScheme = "viber://"
        let tel = "tel"
        let chat = "chat"
        let action = "tel"
        if let url = URL(string: viberScheme) {
            if UIApplication.shared.canopenURL(url) {

                // viber is installed
                var myString: String?
                if action == tel {
                    myString = "\(tel):\(phoneNumber)"
                } else if action == chat {
                    myString = "\(chat):\(phoneNumber)"
                }

                let myUrl = URL(string: viberScheme + (myString ?? ""))

                if let myUrl = myUrl {
                    if UIApplication.shared.canopenURL(myUrl) {
                        if #available(iOS 10.0,*) {
                          UIApplication.shared.open(myUrl,options: [:],completionHandler: nil)
                        } else {
                          UIApplication.shared.openURL(myUrl)
                        }
                    } else {
                        // wrong parameters
                    }
                }
            } else {
                // viber is not installed
            }
        }
    }

出现以下错误

-canopenURL:URL 失败:“viber://” - 错误:“此应用不允许查询方案 viber”

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)