在iOS Swift上发布到Instagram屏幕

问题描述 投票:1回答:1

我正在尝试从我的应用程序轻松共享到Instagram。我想要的是进入下面屏幕截图所示的屏幕。我试过Instagram故事://分享深度链接,我已经阅读了所有这些文档:https://developers.facebook.com/docs/instagram/sharing-to-stories/

然而,无论我做什么,当url scheme动作触发时,它直接将图像分享到故事中。我在这里错过了什么?

enter image description here

这是我的代码摘录:

           if let image = image {
                guard let urlScheme = URL(string: "instagram-stories://share"),
                    let imageData = image.pngData() else {
                    return
                }

                if UIApplication.shared.canOpenURL(urlScheme) {
                    let pasterboardItems = [["com.instagram.sharedSticker.backgroundImage": imageData]]
                    let pasterboardOptions = [UIPasteboard.OptionsKey.expirationDate: Date().addingTimeInterval(60*5)]

                    UIPasteboard.general.setItems(pasterboardItems, options: pasterboardOptions)

                    UIApplication.shared.open(urlScheme, options: [:], completionHandler: nil)
                }
            }
ios swift facebook instagram
1个回答
2
投票
  1. 假设你的image是“png”
  2. 假设您在info.plist(密钥LSApplicationQueriesSchemes)中允许“​​instagram-stories”
© www.soinside.com 2019 - 2024. All rights reserved.