SAURABH SANWAL
SAURABH SANWAL

Reputation: 189

How to get push notification payload inside local notification

I want to achive this from local notificationWhatsApp Incoming Video CallI am developing a webRTC (video calling) application in ios. I am receiving a APNS push notification from server,whenever user receive a incoming video call on the device.

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

How can I store it inside Local Notification?

Upvotes: 3

Views: 2867

Answers (1)

Nikunj Damani
Nikunj Damani

Reputation: 753

If you want to store data in local push notification then you can add the data like this,

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)

Upvotes: 2

Related Questions