1

I want to achive this from local notificationWhatsApp Incoming Video Call iosでwebRTC(ビデオ通話)アプリケーションを開発しています。ユーザーがデバイスで着信ビデオコールを受信するたびに、サーバーからAPNSプッシュ通知を受信して​​います。ローカル通知内でプッシュ通知ペイロードを取得する方法

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

どうすればローカル通知内に保存できますか?

+0

アップルのVoipプッシュサービスとプッシュキットフレームワークを使用してこれを達成しました。アプリがバックグラウンドであるか強制終了している間に、ローカル通知内でペイロードを処理できます。 –

答えて

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)