How to Programmatically check and open an existing app in iOS 8?

后端 未结 6 1999
执笔经年
执笔经年 2021-02-08 04:14

I want to check whether an app is present in my iphone or not. If it is present I want to launch it else open the App Store link of the app.

Please suggest the required

6条回答
  •  隐瞒了意图╮
    2021-02-08 04:57

    You can check if the respective device has an app is installed using:

    // url = "example" (check the following image to understand)
    let canOpen = UIApplication.sharedApplication().canOpenURL(NSURL(string: url as String)!)
    

    Where url is pre configured (have a URL scheme registered for your app in your Info.plist)

    So, if canOpen is true means that app is installed and you can open using:

    UIApplication.sharedApplication().openURL(NSURL(string:url)!)
    

    enter image description here

提交回复
热议问题