2017-06-15 123 views
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 



    } 

它也没有工作,我得到的通知,如果调用超时。

谁可以帮忙?非常感谢

回答

0

您只能定义您想要在推送VoiP推送时看到的内容,这就是您看到您所看到的内容的原因。