I am triggering Local Notification in my iOS app. I am getting the notification only when the device is locked. I want the notification to show on top of my app.
I am triggering notification with the following code:
struct ContentView: View {
var body: some View {
Button {
let content = UNMutableNotificationContent()
content.title = "Cold Water Therapy"
content.body = "Timer ended"
content.sound = UNNotificationSound.init(named: UNNotificationSoundName(rawValue: "iphone_alarm_morning.mp3"))
let trigger = UNTimeIntervalNotificationTrigger(timeInterval: 5, repeats: false)
let request = UNNotificationRequest(identifier: UUID().uuidString, content: content, trigger: trigger)
UNUserNotificationCenter.current().add(request)
} label: {
Text("Trigger notification")
}
}
}
I am getting the notification when the device is locked with the default sound.
How can I get notification on top of my app with UNNotificationSoundName(rawValue: "iphone_alarm_morning.mp3") sound?