After update to iOS14 users have problem with sharing UIImage to the Instagram from application. Story view is presented after open Instagram with image and then disappear. Have anyone else this problem? The example of code below.
func shareToInstagram(shareImage: UIImage) {
let url = URL(string: "instagram-stories://share")!
if UIApplication.shared.canOpenURL(url) {
guard let backgroundData = shareImage.pngData() else { return }
let pasteBoardItems = [
["com.instagram.sharedSticker.backgroundImage": backgroundData as Any]
]
let option: [UIPasteboard.OptionsKey: Any] = [.expirationDate: Date().addingTimeInterval(60 * 5)]
if #available(iOS 10.0, *) {
UIPasteboard.general.setItems(pasteBoardItems,
options: option)
} else {
UIPasteboard.general.items = pasteBoardItems
}
UIApplication.shared.open(url)
}
}
Well, as always FB documentation didn't contain any information. Documentation contains info about minimum resolution of photo, but didn't have any information about maxim resolution and size of the file. After changing the scale factor in UIGraphicsBeginImageContextWithOptions everything is fine.