【发布时间】:2019-05-21 20:38:07
【问题描述】:
为了将数据上传到我的 Firestore 数据库,我应该在哪里运行我的应用程序中的后台线程。
应用程序将在后台或终止,即使用户已关闭应用程序,我仍需要将信息上传到服务器
这段代码好像是在执行线程,但是应该放在哪里呢?我可以把它放在我的 applicationDidEnterBackground 或 applicationWillTerminate 中吗?
DispatchQueue.background(background: {
let checkPointWorker = CheckPointWorker()
checkPointWorker.writeCheckPointsToFirestore()
}, completion:{
// Background job finished
})
【问题讨论】:
-
出于好奇,即使用户终止了应用程序,也需要写入数据库的用例是什么?
标签: swift multithreading firebase google-cloud-firestore grand-central-dispatch