URL模式发布到Instagram故事 [英] URL Scheme to post to Instagram Stories
本文介绍了URL模式发布到Instagram故事的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以将视频或照片直接发布到用户的Instagram帐户的Instagram故事中?对于Instagram上的普通照片共享,您可以使用URL方案并直接打开编辑器.故事也有办法吗?
Is there a way to post a video or photo directly to the Instagram Stories of the user's Instagram account? For a normal photo share on Instagram, you can use the URL Scheme and open the Editor directly. Is there a way for Stories, too?
谢谢!
推荐答案
Swift 4.2版本的 knshn的答案:>
Swift 4.2 version of knshn's answer:
func shareBackgroundImage() {
let image = UIImage(imageLiteralResourceName: "backgroundImage")
if let pngImage = image.pngData() {
backgroundImage(pngImage, attributionURL: "http://your-deep-link-url")
}
}
func backgroundImage(_ backgroundImage: Data, attributionURL: String) {
// Verify app can open custom URL scheme, open if able
guard let urlScheme = URL(string: "instagram-stories://share"),
UIApplication.shared.canOpenURL(urlScheme) else {
// Handle older app versions or app not installed case
return
}
let pasteboardItems = [["com.instagram.sharedSticker.backgroundImage": backgroundImage,
"com.instagram.sharedSticker.contentURL": attributionURL]]
let pasteboardOptions: [UIPasteboard.OptionsKey: Any] = [.expirationDate: Date().addingTimeInterval(60 * 5)]
// This call is iOS 10+, can use 'setItems' depending on what versions you support
UIPasteboard.general.setItems(pasteboardItems, options: pasteboardOptions)
UIApplication.shared.open(urlScheme)
}
这篇关于URL模式发布到Instagram故事的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文