How to open fb and instagram app by tapping on button in Swift

前端 未结 8 2429
佛祖请我去吃肉
佛祖请我去吃肉 2020-11-30 03:17

How can I open Facebook and Instagram app by tapping on a button in swift? Some apps redirect to the Facebook app and open a specific page. How can I do the sam

8条回答
  •  爱一瞬间的悲伤
    2020-11-30 03:46

    In swift 3;

    First you should add this on your Info.plist

    Than you can use this code;

        let instagramUrl = URL(string: "instagram://app")
        UIApplication.shared.canOpenURL(instagramUrl!)
        UIApplication.shared.open(instagramUrl!, options: [:], completionHandler: nil)
    

提交回复
热议问题