iOS 9 not opening Instagram app with URL SCHEME

后端 未结 14 1898
攒了一身酷
攒了一身酷 2020-11-22 06:33

The following URL opens on iOS 8.3 and lower, but it does not work and iOS 9

let instagramURL = NSURL(string: \"instagram://app\")

Why won\

14条回答
  •  礼貌的吻别
    2020-11-22 07:14

    Swift 3.1, Swift 3.2, Swift 4

    if let urlFromStr = URL(string: "instagram://app") {
        if UIApplication.shared.canOpenURL(urlFromStr) {
            if #available(iOS 10.0, *) {
                UIApplication.shared.open(urlFromStr, options: [:], completionHandler: nil)
            } else {
                UIApplication.shared.openURL(urlFromStr)
            }
        }
    }
    

    Add these in Info.plist :

    LSApplicationQueriesSchemes
    
        instagram
    
    

提交回复
热议问题