当我尝试将图像分享到 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)
}
我应该怎么做才能没有收到错误?