从另一个应用程序打开应用程序

时间:2019-07-21 00:52:49

标签: ios swift

当用户选择要使用标签的银行时,我有一个名为“ 银行”的选择器视图,下面显示了用户选择的银行的名称,然后创建了一个按钮名为“ 去银行”,根据客户选择的银行转到银行页面,到目前为止,问题是创建另一个名为“ 打开应用”,即尝试打开用户选择的银行应用程序(如果已将其安装在设备上),但它显示一条警告,指出未安装,我通过在文件中创建应用程序的名称来做到这一点“ info.plist”创建LSAplicationQueriesSchemes并给出银行的每个应用程序的名称,我的问题是它仅适用于单个银行应用程序,其他人不打开它们仅向我显示警告即使已安装该应用程序也未安装在设备上,但我尝试将第二个应用程序的名称放在第一个条件中启用第一个应用程序,但是我没有打开第二个应用程序,有人可以帮我解决这个问题吗?

https://i.stack.imgur.com/zdJwn.png

我说的问题是,第一个应用程序没有问题就打开了它,然后第二个名称“ Santander”没有打开,并运行警告,提示该应用程序尚未安装,尽管该应用程序已安装在设备上。

@IBAction func BotonAbrirappaction(_ sender: UIButton) {
    if labelBancoseleccionado.text == listaBancos[0] {

        if let appURL = URL(string: "BancoEstado://") {
        let canOpen = UIApplication.shared.canOpenURL(appURL)
        print("\(canOpen)")

        let appName = "BancoEstado"
            let appScheme = "\(appName)://"
        let appSchemeURL = URL(string: appScheme)

            if UIApplication.shared.canOpenURL(appSchemeURL! as URL) {

                UIApplication.shared.open(appSchemeURL!, options: [:], completionHandler: nil)
            } else {
                let alert = UIAlertController(title: "Mensaje:", message: "La Aplicacion \(appName) no esta instalada en el telefono, Porfavor descarguela de la App Store para usarla.", preferredStyle: .alert)
                alert.addAction(UIAlertAction(title: "Ok", style: .default, handler: nil))
                self.present(alert, animated: true, completion: nil)
            }
        }
    }

if      labelBancoseleccionado.text == listaBancos[1] {

        if let appURL = URL(string: "Santander://") {
        let canOpen = UIApplication.shared.canOpenURL(appURL)
        print("\(canOpen)")

        let appName = "Santander"
        let appScheme = "\(appName)://"
        let appSchemeURL = URL(string: appScheme)

        if UIApplication.shared.canOpenURL(appSchemeURL! as URL) {

            UIApplication.shared.open(appSchemeURL!, options: [:], completionHandler: nil)

        } else {
            let alert = UIAlertController(title: "Mensaje:", message: "La Aplicacion \(appName) no esta instalada en el telefono, Porfavor descarguela de la App Store para usarla.", preferredStyle: .alert)
            alert.addAction(UIAlertAction(title: "Ok", style: .default, handler: nil))
            self.present(alert, animated: true, completion: nil)
        }
    }

0 个答案:

没有答案