如何检查应用程序是否已安装在手机中 [英] How to check app is installed or not in phone

查看:87
本文介绍了如何检查应用程序是否已安装在手机中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不知道如何检查手机上是否安装了应用程序!或者在安装App时,打开应用程序,否则打开Appstore链接以下载应用程序。我正在使用 swift 3 。我想使用应用名称捆绑包标识符来实现。
谢谢!

I don't know how to check if app is installed or not on phone! Or when App is installed, open the app, otherwise open the Appstore link to download the app. I'm using swift 3. I want to do it using app name or bundle identifier. Thank You!

推荐答案

func openApp(appName:String) {

    let appName = "instagram"
    let appScheme = "/(appName)://app"
    let appUrl = URL(string: appScheme)

    if UIApplication.shared.canOpenURL(appUrl! as URL)
    {
        UIApplication.shared.open(appUrl!)

    } else {
        print("App not installed")
    }

}

这篇关于如何检查应用程序是否已安装在手机中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆