我想将用户的 Instagram 帐户连接到我的应用程序,并能够让他们在 Instagram 上关注其他用户(她/他选择的);或者至少触发 Instagram 应用程序并转到用户的个人资料。我目前正在使用 Swift,那里的文档不是很清楚。真的可以做我想做的事吗?如果是这样,我该怎么做?预先感谢您的帮助。
最佳答案
这个函数将完成这项工作:
如果没有安装instagram app,那么它会在safari中打开instagram的网页。 如果安装了该应用程序,它会在 Instagram 应用程序中打开您想要的页面:)
func openInstagram() {
var instURL: NSURL = NSURL (string: "instagram://user?username=Instagram")! // Replace = Instagram by the your instagram user name
var instWB: NSURL = NSURL (string: "https://instagram.com/instagram/")! // Replace the link by your instagram weblink
if (UIApplication.sharedApplication().canOpenURL(instURL)) {
// Open Instagram application
UIApplication.sharedApplication().openURL(instURL)
} else {
// Open in Safari
UIApplication.sharedApplication().openURL(instWB)
}
}
关于ios - 允许来 self 的应用程序的用户 'Follow on Instagram' (Swift),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29755059/