ios - 绕过 instagram 菜单在 instagram 上共享 (Swift)
问题描述
我正在开发一个应用程序,我可以在其中分享到 instagram,但我想直接分享到 instagram 故事。
目前,当我尝试分享图片时,它正在打开 Instagram 故事菜单,然后我必须再次点击才能分享。
有没有办法绕过这个部分。
代码:
private let instagramStoriesURL = URL(string: "instagram-stories://share")
public func postToInstagramStories(image: UIImage, backgroundTopColorHex: String, backgroundBottomColorHex: String, deepLink: String) {
DispatchQueue.main.async {
guard let urlScheme = self.instagramStoriesURL else {
self.delegate?.error(message: "URL not valid")
return
}
let pasteboardItems = ["com.instagram.sharedSticker.stickerImage": image,
"com.instagram.sharedSticker.backgroundTopColor" : backgroundTopColorHex,
"com.instagram.sharedSticker.backgroundBottomColor" : backgroundBottomColorHex,
"com.instagram.sharedSticker.contentURL": deepLink] as [String : Any]
if #available(iOS 10.0, *) {
let pasteboardOptions = [UIPasteboard.OptionsKey.expirationDate : NSDate().addingTimeInterval(60 * 5)]
UIPasteboard.general.setItems([pasteboardItems], options: pasteboardOptions)
} else {
UIPasteboard.general.items = [pasteboardItems]
}
if #available(iOS 10.0, *) {
UIApplication.shared.open(urlScheme, options: [:], completionHandler: { (success) in
self.delegate?.success()
})
} else {
UIApplication.shared.openURL(urlScheme)
self.delegate?.success()
}
}
}
解决方案
推荐阅读
- java - Redis 的 Redisson 的 API 方法 .unlock() 没有释放锁,尝试从同一个实例
- blazor - 允许@onclick for div 吗?
- python - 为什么在我运行 `plt.savefig()` 之后发生`ValueError: minvalue must be positive`?
- apache - 我的域永久移动了 301,最终加载或不加载我的 Apache 服务器
- ios - iOS Mapbox MGLMapView:使图像适合 MGLMapView
- powershell - 您如何比较 whoami /groups 的输出以检查 powershell 中是否存在某个值?
- python - 使用 eval() 将字符串作为函数调用
- angular - Angular:使用代码的管道正在模型数据上添加 $ 符号
- javascript - WebGL JavaScript 游戏在 Chrome 中导致 STATUS_ACCESS_VIOLATION
- java - Android应用程序运行一段时间后自动终止