我的应用程序始终打开Safari而不是instagram

时间:2019-05-29 20:05:39

标签: swift

我不明白为什么这段代码对我不起作用。 无论我是否拥有Instagram应用程序,我的应用程序是否都可以打开野生动物园。 (有趣的事实。如果我不使用Safari服务,那么一切正常)

var instURL: NSURL = NSURL (string: "instagram://user?username=eazy")! // Replace = Instagram by the your instagram user name
    var instWB: NSURL = NSURL (string: "https://instagram.com/eazy/")! // Replace the link by your instagram weblink

    if (UIApplication.shared.canOpenURL(instURL as URL)) {
        // Open Instagram application
        UIApplication.shared.openURL(instURL as URL)
    } else {
        // Open in Safari
        let svc = SFSafariViewController(url: instWB as URL)
        present(svc, animated: true, completion: nil)


    }

0 个答案:

没有答案
相关问题