当我尝试将图片分享到Instagram故事时,我收到以下错误:此应用程序不允许查询计划instagram故事
虽然我将自定义URL方案instagram-stories添加到LSApplicationQueryScheme中
我遵循了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>
我用以下答案解决了错误:https://stackoverflow.com/a/38393379/5061249
我还试图将LSApplicationQueryScheme定义为字典:(