0
我有以下問題:我收到推送通知,但推送通知的標題和主體沒有得到顯示。推送通知僅顯示我在localizable.string中定義的內容,而不是我在代碼中定義的內容。我在我的應用程序代理下面的代碼:接收推送通知從Sinch,Swift 3
// SINManagedPushDelegate - FORWARD INCOMING PUSH NOTIFICATIONS TO A SINCH CLIENT
func managedPush(_ unused: SINManagedPush, didReceiveIncomingPushWithPayload payload: [AnyHashable: Any], forType pushType: String) {
}
//Describes what happens with handleRemoteNotfication from above
func handleRemoteNotification(_ userInfo: [AnyHashable: Any]) {
let result: SINNotificationResult = (self.client?.relayRemotePushNotification(userInfo))!
if !(self.client != nil) {
let userId: String? = UserDefaults.standard.object(forKey: "userId") as! String?
if userId != nil {
self.initSinchClientWithUserId(userId: userId!)
}
}
if result.isCall() && result.call().isTimedOut {
if #available(iOS 10.0, *) {
let content = UNMutableNotificationContent()
content.categoryIdentifier = "awesomeNotification"
content.title = "Missed Call"
content.body = String(format: "Missed Call from %@", arguments: [result.call().remoteUserId])
content.sound = UNNotificationSound.default()
}
else {
let alert: UIAlertController = UIAlertController(title: "Missed Call", message: String(format: "Missed Call from %@", arguments: [result.call().remoteUserId]), preferredStyle: .alert)
let okAction = UIAlertAction(title: "Ok", style: .default, handler: {_ -> Void in
alert.dismiss(animated: true, completion: nil)
})
alert.addAction(okAction)
self.window?.rootViewController?.present(alert, animated: true, completion: nil)
}
}
self.client?.relayRemotePushNotification(userInfo)
}
func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any]) {
// func application(_ application: UIApplication, didReceiveRemoteNotification data: [AnyHashable : Any]) {
print("Push notification received: \(userInfo)")
print("Remote Notification")
self.sinchPush.application(application, didReceiveRemoteNotification: userInfo)
}
// implementation of SINCallClientDelegate - PRESENTING LOCAL NOTIFICATIONS FOR INCOMING CALLS
private func client(_ client: SINClient, localNotificationForIncomingCall call: SINCall) -> SINLocalNotification {
let notification = SINLocalNotification()
notification.alertAction = "Answer"
notification.alertBody = "Incoming call from \(call.remoteUserId)"
return notification
}
它也沒有工作,我得到的通知,如果調用超時。
誰可以幫忙?非常感謝