ios - 如何在后台为 Firebase 实时数据库设置值?
<p><p>我这样在后台调用 setValue():</p>
<pre><code>func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: , 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)
}
</code></pre>
<p>但从未调用完成 block 。后台不能上传数据吗?</p></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>Apple 允许在后台调用少数功能</p>
<ol>
<li>麦克风</li>
<li>位置更新</li>
<li>蓝牙配件</li>
<li>网络电话</li>
</ol></p>
<p style="font-size: 20px;">关于ios - 如何在后台为 Firebase 实时数据库设置值?,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/41566373/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/41566373/
</a>
</p>
页:
[1]