1

I want to achive this from local notificationWhatsApp Incoming Video Call我正在开发一个webRTC(视频通话)应用程序在ios中。每当用户在设备上收到传入视频呼叫时,我都会收到来自服务器的APNS推送通知。如何获得本地通知内的推送通知有效载荷

{ 
    "aps" : { 
     "alert" : "Incoming video call from - Bob", 
     "badge" : 1, 
     "sound" : "bingbong.mp3", 
     "userdata" : {JSON} 
    } 
} 

如何将其存储在本地通知中?

+0

感谢您的回答,我使用apple Voip推送服务和Pushkit Framework实现了它,它允许我在本地通知中处理我的有效内容,而应用程序处于后台或强行终止状态。 –

回答

1

嗨,如果你想存储数据在本地推送通知,那么你可以添加这样的数据试试看。

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)