嗨,如果你想存儲數據在本地推送通知,那麼你可以添加這樣的數據試試看。
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推送服務和Pushkit Framework實現了它,它允許我在本地通知中處理我的有效內容,而應用程序處於後臺或強行終止狀態。 –