objective-c - 打开 Instagram Native 链接

标签 objective-c facebook instagram

要打开 Facebook Native 配置文件,我可以使用:

NSURL *url = [NSURL URLWithString:@"fb://profile/<id>"];
[[UIApplication sharedApplication] openURL:url];

有什么方法可以对 Instagram 个人资料做同样的事情吗?

最佳答案

以下代码段将使用用户名在您的设备上打开 instagram 应用。

Objective-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")
    })
}

如果您想了解更多详情,可以引用以下Documentation link

关于objective-c - 打开 Instagram Native 链接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16369798/

相关文章:

ios - 如何在 iOS 中从设备中删除应用程序时删除我的应用程序日历的所有事件

objective-c - Cocoa API - 它是否包含 diff api?

Facebook graph api 搜索结果取决于位置?

android - 我们如何通过我们的应用程序在 Instagram 上关注某人?

javascript - 向 Instagram feed 添加分页或延迟加载

iphone - 将文件复制到文档目录导致失败

iphone - 如何使用 pinch zoom(UIPinchGestureRecognizer) 更改 UITextView 的宽度?

c# - 在 Windows Azure 中处理联合身份验证中的注销

java - python 服务器上的 API 参数中提供的 appsecret_proof 无效

android - 如何在 Flutter 中集成 Instagram 登录