gpt4 book ai didi

ios - 如何在后台为 Firebase 实时数据库设置值?

转载 作者:塔克拉玛干 更新时间:2023-11-02 22:54:33 25 4
gpt4 key购买 nike

我在后台调用 setValue() 是这样的:

func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {

let semaphore: DispatchSemaphore = DispatchSemaphore(value: 0)
let ref = FIRDatabase.database().reference().child("data")
let data: NSDictionary = [
"test" : "test"
]
ref.setValue(data, withCompletionBlock:{
(error, reference) in
if error != nil {
print(error!)
} else {
print("success")
semaphore.signal()
}
})
_ = semaphore.wait(timeout: .distantFuture)
completionHandler(.newData)
}

但是从未调用完成 block 。后台不能上传数据吗?

最佳答案

Apple 允许在后台调用少数功能

  1. 麦克风
  2. 位置更新
  3. 蓝牙配件
  4. 电话

关于ios - 如何在后台为 Firebase 实时数据库设置值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41566373/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com