【发布时间】:2022-08-18 23:26:30
【问题描述】:
我正在从我的应用程序中发布 Instagram 故事,它运行良好。但是,当我在存储 URL 的位置添加 UIPasteboard 字符串值时,将其粘贴到 instagram 链接时它会被清除。我注意到 Instagram 在启动时正在清除粘贴板项目。有什么方法可以将粘贴板项目保留在 Instagram 中?这是我的代码 sn-p:
let urlScheme = URL(string:\"instagram-stories://share\")!
if UIApplication.shared.canOpenURL(urlScheme) {
UIPasteboard.general.string = Global.hostURL // THIS GETS CLEARED
let pasteBoardItems:Array<[String:Any]> = [
[\"com.instagram.sharedSticker.backgroundImage\" : background.pngData()!]
]
let expirationDate = Date().addingTimeInterval(60 * 5)
let pasteBoardOptions = [UIPasteboard.OptionsKey.expirationDate: expirationDate]
UIPasteboard.general.setItems(pasteBoardItems, options: pasteBoardOptions)
UIApplication.shared.open(urlScheme)
}
标签: ios swift uipasteboard instagram-story