我已经实现了VOIP推送,该推送从Amazon SNS发送推送通知。当我们处于开发模式时,push在所有三种模式(活动,背景,终止)下都可以正常工作,并且正在更新firebase db(timestamp,lat,long),但是当我们将其放到testflight上并检查生产时,push就来了,但是没有更新Firebase数据库。我们已经在开发模式下通过debugger(breakpoint)对此进行了测试。 为了确保推送即将到来,我们将本地通知放入下面的代码中
当应用终止但不更新生产环境中的数据库时,也将推送通知。
func pushRegistry(_ registry: PKPushRegistry, didReceiveIncomingPushWith payload: PKPushPayload, for type: PKPushType, completion: @escaping () -> Void){
var arrTemp = [AnyHashable: Any]()
arrTemp = payload.dictionaryPayload
let _ : Dictionary <String, AnyObject> = arrTemp["aps"] as! Dictionary<String, AnyObject>
// call back function from getting lat and long from location Manager
Locator.currentPosition(accuracy: .city, onSuccess: { (loc) -> (Void) in
isUpdatedUsingSilentPush = true
if UIApplication.shared.applicationState == UIApplicationState.background ||
UIApplication.shared.applicationState == UIApplicationState.inactive {
if self.isUserLoggedIn{
DispatchQueue.main.async(execute: {
// inside this function we are sending local notification(for testing purpose) as well updating firebase DB
self.sendLocationToFirebase(manager: Locator, Location: loc)
})
}
}else{
self.sendLocationToFirebase(manager: Locator, Location: loc)
}
}) { (err, loct) -> (Void) in
print(err)
print(loct as Any)
}
completion()
}
答案 0 :(得分:0)
请确保您要调用的函数必须在30秒或更短的时间内处理Firebase,请遵循此“ http://www.nikola-breznjak.com/blog/ios/create-native-ios-app-can-receive-voip-push-notifications/”