【发布时间】:2017-03-08 10:33:58
【问题描述】:
当用户终止应用时,如何将图片上传到 Firebase 存储?
这是我的代码:
firebaseRef.child("\(uid)/\(filePath)").put(data, metadata: metadata) { (metadata, error) in
// NOTE: This spot never reaches when user closes the app
if error != nil || metadata == nil {
log.error("Fail to store image in cloud storage")
} else {
// Do something with the metadata url
}
如您所见,如果用户终止应用并且我无法将用户的图像上传到 Firebase 存储,则异步完成块永远不会完成
如何防止用户在上传图片后终止应用?我有一个初步的想法。能否将图片暂时存入CoreData/NSUserDefaults,等用户再次打开应用后重试上传?
【问题讨论】:
标签: swift firebase firebase-storage