My is downloading a .wav file and moving it to Library/Sounds, then scheduling a local notification via with that ’s file name. This request sends notifications as expected, but the sound I have added only aloud when the phone is , not when the notification is getting delivered to the phone’s lock screen. However, if I use UNNotificationSound.default() instead of my custom sound, the default push sound will play both on the lock screen and when the device is unlocked. Anyone have any ideas what could be causing this issue? My code is simple:

let soundName = "demoSound.wav" // (or nil to use default)

let center = UNUserNotificationCenter.current()

let content = UNMutableNotificationContent()
content.title = "Title"
content.body = "Body";
content.sound = soundName.flatMap { UNNotificationSound(named: $0) } ??  UNNotificationSound.default()

let trigger = UNTimeIntervalNotificationTrigger(timeInterval: 60, repeats: true)
let identifier = "PushNotifierLocalNotification"
let request = UNNotificationRequest(identifier: identifier, content: content, trigger: trigger)
center.add(request, withCompletionHandler: nil)

Source link


Please enter your comment!
Please enter your name here