【发布时间】:2017-01-10 10:15:44
【问题描述】:
我这样在后台调用 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)
}
但从未调用完成块。后台不能上传数据吗?
【问题讨论】:
-
遇到了同样的问题。对其他服务器的 POST 请求在后台工作,但 Firebase 什么都不做
-
这个@Shangri-La 有更新吗?我尝试了@DimaRostopira 的建议,但没有成功。
标签: ios swift firebase firebase-realtime-database