Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/108.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios &引用;Onesignal for Voip推送“;及;Firebase云消息传递“;don';我们不能一起工作_Ios_Swift_Firebase_Google Cloud Messaging_Onesignal - Fatal编程技术网

Ios &引用;Onesignal for Voip推送“;及;Firebase云消息传递“;don';我们不能一起工作

Ios &引用;Onesignal for Voip推送“;及;Firebase云消息传递“;don';我们不能一起工作,ios,swift,firebase,google-cloud-messaging,onesignal,Ios,Swift,Firebase,Google Cloud Messaging,Onesignal,我正在集成由“实时数据库”中的更新触发的“Firebase云消息传递”,在与一个用于向IOS设备发送Voip推送通知的信号集成之前,它一直工作正常。 发送Voip推送通知的一个信号工作正常 有人知道我的代码发生了什么吗?如果你能在下面更正我的代码,这对我会非常有帮助(即使只是建议,教我如何解决问题也是很大的帮助) 已经尝试在没有Firebase的情况下使用一个信号发送常规推送通知和Voip推送通知,但是一个信号技术支持提到“我们不建议在Voip和常规推送中使用相同的应用程序。” 并在集成一个信号

我正在集成由“实时数据库”中的更新触发的“Firebase云消息传递”,在与一个用于向IOS设备发送Voip推送通知的信号集成之前,它一直工作正常。 发送Voip推送通知的一个信号工作正常

有人知道我的代码发生了什么吗?如果你能在下面更正我的代码,这对我会非常有帮助(即使只是建议,教我如何解决问题也是很大的帮助)

已经尝试在没有Firebase的情况下使用一个信号发送常规推送通知和Voip推送通知,但是一个信号技术支持提到“我们不建议在Voip和常规推送中使用相同的应用程序。”

并在集成一个信号时添加了以下UNNotificationServiceExtension

class NotificationService: UNNotificationServiceExtension {

var contentHandler: ((UNNotificationContent) -> Void)?
var receivedRequest: UNNotificationRequest!
var bestAttemptContent: UNMutableNotificationContent?

override func didReceive(_ request: UNNotificationRequest, withContentHandler contentHandler: @escaping (UNNotificationContent) -> Void) {
    self.receivedRequest = request;
    self.contentHandler = contentHandler
    bestAttemptContent = (request.content.mutableCopy() as? UNMutableNotificationContent)

    if let bestAttemptContent = bestAttemptContent {
        OneSignal.didReceiveNotificationExtensionRequest(self.receivedRequest, with: self.bestAttemptContent)
        contentHandler(bestAttemptContent)
    }
}

override func serviceExtensionTimeWillExpire() {
    // Called just before the extension will be terminated by the system.
    // Use this as an opportunity to deliver your "best attempt" at modified content, otherwise the original push payload will be used.
    if let contentHandler = contentHandler, let bestAttemptContent =  bestAttemptContent {
        OneSignal.serviceExtensionTimeWillExpireRequest(self.receivedRequest, with: self.bestAttemptContent)
        contentHandler(bestAttemptContent)
       }
    }
}

您应该使用
可用内容
标志

关于Firebase文档,您必须以某种方式传递
content\u available
参数。这对你的情况可能有帮助


您是否检查推送令牌是否发送到fcm服务器?
class NotificationService: UNNotificationServiceExtension {

var contentHandler: ((UNNotificationContent) -> Void)?
var receivedRequest: UNNotificationRequest!
var bestAttemptContent: UNMutableNotificationContent?

override func didReceive(_ request: UNNotificationRequest, withContentHandler contentHandler: @escaping (UNNotificationContent) -> Void) {
    self.receivedRequest = request;
    self.contentHandler = contentHandler
    bestAttemptContent = (request.content.mutableCopy() as? UNMutableNotificationContent)

    if let bestAttemptContent = bestAttemptContent {
        OneSignal.didReceiveNotificationExtensionRequest(self.receivedRequest, with: self.bestAttemptContent)
        contentHandler(bestAttemptContent)
    }
}

override func serviceExtensionTimeWillExpire() {
    // Called just before the extension will be terminated by the system.
    // Use this as an opportunity to deliver your "best attempt" at modified content, otherwise the original push payload will be used.
    if let contentHandler = contentHandler, let bestAttemptContent =  bestAttemptContent {
        OneSignal.serviceExtensionTimeWillExpireRequest(self.receivedRequest, with: self.bestAttemptContent)
        contentHandler(bestAttemptContent)
       }
    }
}