swift - 在 firestore 上自动更新的计时器

标签 swift firebase google-cloud-firestore

<分区>

我目前正在编写一个使用 Cloud Firestore 作为数据库的 IOS 应用。该应用程序的功能之一是需要在屏幕上显示的滴答计时器,以供用户显示功能剩余的时间。问题是我目前正在使用计时器,但这不起作用,因为当我退出应用程序时,它将停止更新数据库剩余时间。关于如何解决这个问题有什么建议吗?

最佳答案

当您的应用程序关闭时,您将无法与您的代码进行交互。 iOS 是严格的,一旦您的应用关闭,您有 30 秒的时间来处理任何必要的事情。您的应用已暂停常规事件,

正如@matt 提到的:

A timer can run in the background only if both the following are true:

Your app for some other reason runs in the background. (Most apps don't; most apps are suspended when they go into the background.) And: The timer was running already when the app went into the background.

我还建议看这里: Swift 3 - How to make timer work in background

关于swift - 在 firestore 上自动更新的计时器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53894126/

相关文章:

ios - "' NSOffState ' is unavailable in Swift"

swift - 如何使用 FireStore 和云功能创建开发环境

firebase - 如何在文档中循环浏览子集合

javascript - 如何获取 firebase firestore 生成的 id

javascript - 如何从不同设备连接到 firestore 上的同一文档?

ios - 为什么在 Swift 4 中使用委托(delegate)传递数据失败

SwiftUI 表在 macOS Big Sur 上没有动画解雇

arrays - Swift 2.2 和 3.0 之间的语法变化

android - Kotlin - 如何执行 onCompleteListener 以从 Firestore 获取数据?

firebase - 尝试按照部署指令部署多个功能导致错误,arg 太多