Skip to content

ahmetbostanciklioglu/NotificationsSwiftUI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 

Repository files navigation

🔔 Notifications SwiftUI

A minimal SwiftUI example for scheduling local notifications with UNUserNotificationCenter.

Platform Swift SwiftUI Xcode Stars Last Commit

📖 Overview

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.

✨ Features

  • 🔐 Requests notification authorization for alerts, sound, and badge via UNUserNotificationCenter.
  • ⏱️ Schedules a local notification using a UNTimeIntervalNotificationTrigger (fires after 5 seconds).
  • 🚫 Shows a SwiftUI alert prompting the user to enable notifications when permission is denied.
  • 🧩 Centralizes all notification content and UI strings in a single Notifications enum for easy configuration.
  • 🎨 Uses a reusable View extension for consistent button styling.

📸 Preview

Simulator Screenshot - iPhone 17 Pro - 2025-12-03 at 22 41 58 Screenshot 2025-12-03 at 22 42 27 Screenshot 2025-12-03 at 22 42 41

🚀 Getting Started

git clone https://github.com/ahmetbostanciklioglu/NotificationsSwiftUI.git
cd NotificationsSwiftUI
open NotificationsSwiftUI.xcodeproj

Then 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.

📋 Requirements

  • iOS 26.1 or later
  • Xcode 16 or later
  • Swift 5.0

🧑‍💻 Author

Ahmet Bostancıklıoğlu@ahmetbostanciklioglu · ahmetbostancikli@gmail.com

⭐ If this helped you, consider giving the repo a star!

About

Minimal SwiftUI sample for scheduling local notifications with UNUserNotificationCenter

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages