How to show local notification always at the same time?

Uplift iOS Interview

"Uplift iOS Interview" is a comprehensive guide to help aspiring iOS developers soar to new heights in their careers. This book is an indispensable tool for anyone looking to crack the iOS interview and impress their future employers with their technical prowess. With in-depth coverage of Swift, AutoLayout, SwiftUI, Multithreading, Memory management so on and so forth, this book is a treasure trove of knowledge for anyone looking to uplift their iOS development career.

For local notifications, you need to generate the notification content and provide a time or location. Both Local and remote notifications inform the user to do specific action by displaying a notification badge/alert with/without sound. The badge generally shows when the app is on background or not running state. The local notification remind user that he has some relevant things to do in the app. As notification is disruptive and it hurts user’s attention, you must ask for permission to show them.

The permission part is really simple and it is same as all the other type of permission in iOS –

            .requestAuthorization(options: [.alert, .sound, .badge]) { granted, _  in
                // Do something when granted

Let’s create notification content –

let content = UNMutableNotificationContent()
content.title = "Content title"
content.subtitle = "Some text"

Get ahead of the competition and ace your next iOS interview with expert-curated resources. Check out the collection of SwiftUI and Swift interview questions and answers, behavioral interview tips, and the popular custom layout contents. Plus, go through the new section for Engineering Manager to help you excel in your career!

Join my free Newsletter 🚀

Now create a trigger with a specific time. Here, the notification will be launched at the same(8.00AM) time daily.

var dateComponents = Calendar.current.dateComponents([.year, .month, .day], from: Date())
dateComponents.hour = 8
let trigger = UNCalendarNotificationTrigger(dateMatching: dateComponents, repeats: true)

Finally add the notification in the UNUserNotificationCenter to launch.

let request = UNNotificationRequest(identifier: UUID().uuidString, content: content, trigger: trigger)

UNUserNotificationCenter.current().add(request) { error in
    if let error = error {

Rev Up Your iOS Skills: Take a Dynamic Learning Journey
iOS Career Boost

iOS Career Boost is the ultimate learning journey to elevate your iOS development career through a dynamic blend of visual learning, handy cheat sheets, coding practice materials, and expertly curated tips and tricks

Get Ready to Shine: Mastering the iOS Interview

Enjoying the articles? Get the inside scoop by subscribing to my newsletter.

Get access to exclusive iOS development tips, tricks, and insights when you subscribe to my newsletter. You'll also receive links to new articles, app development ideas, and an interview preparation mini book. Your email address will only be used for the purpose of sending the newsletter and will not be shared with third parties or advertisers. Rest assured that we value your privacy and will not spam your inbox.

Connect with me on

Twitter and LinkedIn and don't hesitate to reach out with any questions about this post. Thank you for reading.

If you know someone who would benefit from reading this article, please share it with them.