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)