Code: ` let url = URL(string: "instagram://app")!
if !UIApplication.shared.canOpenURL(url) {
showAlert(title: "Error", message: "インスタグラムがインストールされていません")
return
}
var activityItem: [Any] = []
if let videUrl = videUrl {
activityItem = [ImageActivityItem(videUrl)]
} else {
activityItem = [ImageActivityItem(image)]
}
let activityVC = UIActivityViewController(activityItems: activityItem, applicationActivities: nil)
activityVC.popoverPresentationController?.sourceView = view
self.present(activityVC, animated: true)
activityVC.completionWithItemsHandler = { (activity, success, items, error) in
print("Activity: \(activity) Success: \(success) Items: \(items) Error: \(error)")
DispatchQueue.main.async {
if success {
print("onDone")
self.deleteFile(url: url)
}
}
}`
Log:
2023-05-23 12:41:34.550747+0900 noFilterApp[21146:7539324] [default] LaunchServices: store (null) or url (null) was nil: Error Domain=NSOSStatusErrorDomain Code=-54 "process may not map database" UserInfo={NSDebugDescription=process may not map database, _LSLine=66, _LSFunction=_LSServer_GetServerStoreForConnectionWithCompletionHandler} 2023-05-23 12:41:34.550819+0900 noFilterApp[21146:7539324] [default] Attempt to map database failed: permission was denied. This attempt will not be retried. 2023-05-23 12:41:34.550858+0900 noFilterApp[21146:7539324] [db] Failed to initialize client context with error Error Domain=NSOSStatusErrorDomain Code=-54 "process may not map database" UserInfo={NSDebugDescription=process may not map database, _LSLine=66, _LSFunction=_LSServer_GetServerStoreForConnectionWithCompletionHandler} 2023-05-23 12:41:34.551352+0900 noFilterApp[21146:7539324] [default] LaunchServices: store (null) or url (null) was nil: Error Domain=NSOSStatusErrorDomain Code=-54 "process may not map database" UserInfo={NSDebugDescription=process may not map database, _LSLine=66, _LSFunction=_LSServer_GetServerStoreForConnectionWithCompletionHandler} 2023-05-23 12:41:34.551383+0900 noFilterApp[21146:7539324] [default] Attempt to map database failed: permission was denied. This attempt will not be retried. 2023-05-23 12:41:34.551417+0900 noFilterApp[21146:7539324] [db] Failed to initialize client context with error Error Domain=NSOSStatusErrorDomain Code=-54 "process may not map database" UserInfo={NSDebugDescription=process may not map database, _LSLine=66, _LSFunction=_LSServer_GetServerStoreForConnectionWithCompletionHandler} 2023-05-23 12:41:34.551615+0900 noFilterApp[21146:7539324] [default] -imageForImageDescriptor: can do IO please adopt -imageForDescriptor: for IO free drawing or -prepareImageForDescriptor: if IO is allowed. (This will become a fault soon.)