티스토리 뷰

macOS, iOS

[iOS] 인스타그램에서 열기

SweetDev 2021. 6. 1. 12:56
                let screenName = data?.instagram ?? "" // CHANGE THIS

                let appURL = URL(string: "instagram://user?username=\(screenName)")!
                let webURL = URL(string: "https://instagram.com/\(screenName)")!

                if UIApplication.shared.canOpenURL(appURL) {
                  if #available(iOS 10.0, *) {
                    UIApplication.shared.open(appURL, options: [:], completionHandler: nil)
                  } else {
                    UIApplication.shared.openURL(appURL)
                  }
                } else {
                  // redirect to safari because the user doesn't have Instagram
                  if #available(iOS 10.0, *) {
                    UIApplication.shared.open(webURL, options: [:], completionHandler: nil)
                  } else {
                    UIApplication.shared.openURL(webURL)
                  }
                }
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2025/01   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
글 보관함