I am trying to copy a photo image to paste to Instagram Stories as the background image, and in parallel, copy a string, to manually paste thereafter via the Instagram Stories Link feature. I have developed a workaround solution that works, but lacks in reliability. I've appended it below. For example, if the Instagram mobile app had already been closed, then my workaround won't work. In addition, there are times when a prompt to "Allow Paste" pops up prior to pasting to Instagram, and in those instances, the delay again causes the workaround to fail. I have seen this is request is possible in examining the "NGL" iOS app, and am wondering how I might able to replicate their share behavior. The deliverable is this coded solution in Swift. My workaround (I had to replace bracket with parentheses in order to paste into job description): func presentToIG(with instagramUrlScheme: URL, _ pngImage: Data) ( let pasteboardItems = [["com.instagram.sharedSticker.backgroundImage": pngImage]] let pasteboardOptions: [UIPasteboard.OptionsKey: Any] = [.expirationDate: Date().addingTimeInterval(60 * 5)] UIPasteboard.general.setItems(pasteboardItems, options: pasteboardOptions) UIApplication.shared.open(urlScheme, options: [:]) ( isDone in if isDone ( DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 0.8) ( UIPasteboard.general.string = urlLinkString ) ) ) )
Success story sharing