Push notification 如何在本地通知中获取推送通知负载
我正在用ios开发一个webRTC(视频通话)应用程序。每当用户在设备上接收到传入的视频呼叫时,我都会从服务器接收到APNS推送通知Push notification 如何在本地通知中获取推送通知负载,push-notification,swift3,apple-push-notifications,ios10,uilocalnotification,Push Notification,Swift3,Apple Push Notifications,Ios10,Uilocalnotification,我正在用ios开发一个webRTC(视频通话)应用程序。每当用户在设备上接收到传入的视频呼叫时,我都会从服务器接收到APNS推送通知 { "aps" : { "alert" : "Incoming video call from - Bob", "badge" : 1, "sound" : "bingbong.mp3", "userdata" : {JSON} } } 如何将其存储在本地通知中?如果要在本地推送通知
{
"aps" : {
"alert" : "Incoming video call from - Bob",
"badge" : 1,
"sound" : "bingbong.mp3",
"userdata" : {JSON}
}
}
如何将其存储在本地通知中?如果要在本地推送通知中存储数据,则可以这样添加数据
let interval = TimeInterval(1)
let trigger = UNTimeIntervalNotificationTrigger(timeInterval: interval, repeats: false)
let content = UNMutableNotificationContent()
content.title = "Incoming video call from - Bob"
content.body = "Your body"
content.sound = UNNotificationSound.init(named: "CustomSound.mp3")
content.badge = "Your badge number"
content.userInfo = ["userData": YOUR_USER_DATA from remote]
let req = UNNotificationRequest(identifier: "localPushNotification", content: content, trigger: trigger)
let center = UNUserNotificationCenter.current()
center.add(req, withCompletionHandler: nil)
感谢您的回答,我使用apple Voip推送服务和推送套件框架实现了它,它允许我在本地通知中处理负载,而应用程序处于后台或强制终止。