如何打开instagram查询方案以分享故事?

时间:2019-07-15 20:29:13

标签: ios swift instagram-api instagram-story

当我尝试与instagram故事共享图像时,出现以下错误: 该应用不允许查询计划instagram故事

尽管我在 LSApplicationQueriesSchemes

中添加了自定义URL方案 instagram-stories

我遵循了Instagram的文档:https://developers.facebook.com/docs/instagram/sharing-to-stories/#ios-developers,我的代码如下:

private func shareToInstagramStories() {
    guard let imagePNGData = UIImage(named: "myImage").pngData() else { return }
    guard let instagramStoryUrl = URL(string: "instagram-stories://share") else { return }
    guard UIApplication.shared.canOpenURL(instagramStoryUrl) else { return }

    let itemsToShare: [[String: Any]] = [["com.instagram.sharedSticker.backgroundImage": imagePNGData]]
    let pasteboardOptions: [UIPasteboard.OptionsKey: Any] = [.expirationDate: Date().addingTimeInterval(60 * 5)]
    UIPasteboard.general.setItems(itemsToShare, options: pasteboardOptions)
    UIApplication.shared.open(instagramStoryUrl, options: [:], completionHandler: nil)
}

我应该怎么办才能得到错误消息?

2 个答案:

答案 0 :(得分:1)

尝试仅放置<string>instagram</string>。不一定是完整路径,而是方案url的基础。

<key>LSApplicationQueriesSchemes</key>
<array>
    <string>instagram</string>
</array>

答案 1 :(得分:0)

好的,我通过以下答案解决了该错误:https://stackoverflow.com/a/38393379/5061249

我还试图将LSApplicationQueriesSchemes定义为dict:(