ios - 发布到 Instagram 故事的 URL 方案

标签 ios objective-c instagram instagram-api url-scheme

有没有办法将视频或照片直接发布到用户 Instagram 帐户的 Instagram 快拍?对于 Instagram 上的普通照片分享,您可以使用 URL Scheme 并直接打开编辑器。故事也有方法吗?

谢谢!

最佳答案

Swift 4.2 版本knshn's answer :

func shareBackgroundImage() {
    let image = UIImage(imageLiteralResourceName: "backgroundImage")

    if let pngImage = image.pngData() {
        backgroundImage(pngImage, attributionURL: "http://your-deep-link-url")
    }
}

func backgroundImage(_ backgroundImage: Data, attributionURL: String) {
    // Verify app can open custom URL scheme, open if able

    guard let urlScheme = URL(string: "instagram-stories://share"),
        UIApplication.shared.canOpenURL(urlScheme) else {
            // Handle older app versions or app not installed case

            return
    }

    let pasteboardItems = [["com.instagram.sharedSticker.backgroundImage": backgroundImage,
                            "com.instagram.sharedSticker.contentURL": attributionURL]]
    let pasteboardOptions: [UIPasteboard.OptionsKey: Any] = [.expirationDate: Date().addingTimeInterval(60 * 5)]

    // This call is iOS 10+, can use 'setItems' depending on what versions you support
    UIPasteboard.general.setItems(pasteboardItems, options: pasteboardOptions)

    UIApplication.shared.open(urlScheme)
}

关于ios - 发布到 Instagram 故事的 URL 方案,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44283082/

相关文章:

ios - 将按钮从过滤后的图像重置为原始图像

iphone - 应用程序仅通过 WiFi 加载数据

ios - CoreTelephony eSIM 功能无法在设备上运行

iPhone 按钮选择状态

ios - 如何制作类似 Instagram 的标签页?

ios - 谓词获取所有对象

ios - 如何仅以英文获取 Googleapis 响应?

objective-c - 来自文件字符串的 dictionaryWithContentsOfFile

javascript - knockout 绑定(bind)错误

api - 我们如何为客户获取实时 Instagram 位置通知?