I encountered a very difficult problem. After Rongyun pushed a message, the client needed to judge the field of appData to make different personalized jumps. However, in remote push, iOS clients can obtain AppData. However, local push cannot obtain AppData, and Rongyun does not configure local push data. But the demand must be realized, so I thought of the rongyun side of the notice to intercept, and then play a push, so that they play push to want to match what parameters with what parameters.
func onRCIMCustomLocalNotification(_ message: RCMessage! , withSenderName senderName: String!) -> Bool { if let msg = message.content as? RCTextMessage{ if msg.extra ! = "" && msg.extra ! = "3" && msg.extra ! = "2" && msg.extra ! = "1"{ let rcDic = [ "tId": message.targetId ?? "" ] as [String:Any] addNotification(titleString: senderName, bodyString: msg.content, rcUserInfo: rcDic, appData: getDictionaryFromJSONString(jsonString: MSG. Extra) return true}else{return true; }}else{return false}} /** Add Create and add local notification */ func addNotification(titleString: String, bodyString: String, rcUserInfo: [String:Any], appData: [String: Any]) {/ / set to push content to let the content = UNMutableNotificationContent () the title = titleString content. body = bodyString content.userInfo = [ "rc": rcUserInfo, "AppData: appData] / / / / set the request set up notifications triggers identifier let requestIdentifier =" com. CustomRC. RCNotification "/ / set a notification request let request = UNNotificationRequest(identifier: requestIdentifier,content: content, trigger: Nil) / / add the notification request to send center UNUserNotificationCenter. The current (). The add (request) {error if the error in = = nil {print (" Time Interval Notification scheduled: \(requestIdentifier)") } }Copy the code
}