ios - 如何打开 Instagram 查询方案以分享到故事?
问题描述
当我尝试将图像分享到 Instagram 故事时,我收到以下错误: 不允许此应用查询方案 instagram-stories
虽然我将自定义 URL 方案instagram-stories添加到LSApplicationQueriesSchemes
我遵循了 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)
}
我应该怎么做才能没有收到错误?
解决方案
尽量只放<string>instagram</string>
. 不需要完整路径,而是方案 url 的基础。
<key>LSApplicationQueriesSchemes</key>
<array>
<string>instagram</string>
</array>
推荐阅读
- ruby-on-rails - 安装 Rails 6 - Bundler 找不到 gem actionpack 的兼容版本
- google-apps-script - 以编程方式删除脚本
- python - 更改选择框 Selenium 的值
- c# - Asp.net Core HttpClient 有很多 TIME_WAIT 或 CLOSE_WAIT 连接
- python - 滚动散景下拉选项
- javascript - 从今天到前一天的javascript时间计数器
- java - 如何获取保存在 USER_ID 中的数据?
- amazon-web-services - 从 CloudFormation 启用 Aurora 数据 API
- asp.net-mvc - 在 .Net Framework 旧版应用程序中使用会话 cookie 和/或 JWT 不记名令牌进行身份验证
- gnuradio - 在 GNURadio 上使用 Bladerf 的 QPSK 调制器解调器