打开链接到Instagram Native [英] Open Link to Instagram Native
本文介绍了打开链接到Instagram Native的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
要打开Facebook Native配置文件,我可以使用:
To open a Facebook Native profile, I can use:
NSURL *url = [NSURL URLWithString:@"fb://profile/<id>"];
[[UIApplication sharedApplication] openURL:url];
有没有办法为Instagram个人资料做同样的事情?
Is there any way to do the same thing for an Instagram profile?
推荐答案
以下Snippet将使用userName在您的设备上打开instagram应用程序。
Following Snippet will open instagram app on your device with userName.
目标C
NSURL *instagramURL = [NSURL URLWithString:@"instagram://user?username=USERNAME"];
if ([[UIApplication sharedApplication] canOpenURL:instagramURL]) {
[[UIApplication sharedApplication] openURL:instagramURL];
}
Swift
var instagramURL: NSURL = NSURL(string: "instagram://user?username=USERNAME")
if UIApplication.sharedApplication().canOpenURL(instagramURL) {
UIApplication.sharedApplication().openURL(instagramURL)
}
Swift 3.0
let instagramURL:URL = URL(string: "instagram://user?username=USERNAME")!
if UIApplication.shared.canOpenURL(instagramURL) {
UIApplication.shared.open(instagramURL, options:[:], completionHandler: { (Bool) in
print("Completion block")
})
}
如果你想要更多的细节,你可以参考遵循文档链接
if you want more details about it you can refere following Documentation link
这篇关于打开链接到Instagram Native的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文