A minimal SwiftUI example for scheduling local notifications with UNUserNotificationCenter.
Notifications SwiftUI is a compact iOS sample project that demonstrates how to request notification permission and schedule a local notification in SwiftUI. Tapping a single button asks the user for authorization and, once granted, delivers a time-interval notification a few seconds later. If permission is denied, the app surfaces an alert directing the user to enable notification access in Settings.
The project keeps its concerns cleanly separated: an enum-based configuration holds all notification content and strings, an ObservableObject view model handles the scheduling logic, and the view stays focused on presentation.
- 🔐 Requests notification authorization for alerts, sound, and badge via
UNUserNotificationCenter. - ⏱️ Schedules a local notification using a
UNTimeIntervalNotificationTrigger(fires after 5 seconds). - 🚫 Shows a SwiftUI
alertprompting the user to enable notifications when permission is denied. - 🧩 Centralizes all notification content and UI strings in a single
Notificationsenum for easy configuration. - 🎨 Uses a reusable
Viewextension for consistent button styling.
git clone https://github.com/ahmetbostanciklioglu/NotificationsSwiftUI.git
cd NotificationsSwiftUI
open NotificationsSwiftUI.xcodeprojThen select a simulator or device and press Command-R to build and run. Tap Send Notifications, grant permission when prompted, and the notification will arrive a few seconds later.
- iOS 26.1 or later
- Xcode 16 or later
- Swift 5.0
Ahmet Bostancıklıoğlu — @ahmetbostanciklioglu · ahmetbostancikli@gmail.com
⭐ If this helped you, consider giving the repo a star!


