SystemNotification
Mimic the native iOS system notification in SwiftUI.
Install / Use
/learn @danielsaidi/SystemNotificationREADME
SystemNotification
SystemNotification is a SwiftUI library that lets you mimic the native iOS system notification that is presented when you toggle silent mode, connect your AirPods, etc.
<p align="center"> <img src="Resources/Demo.gif" width=400 /> </p>System notifications can be styled and customized. You can use a native-looking SystemNotificationMessage view as the content view, or any custom view.
Installation
SystemNotification can be installed with the Swift Package Manager:
https://github.com/danielsaidi/SystemNotification.git
Getting started
With SystemNotification, you can add a system notification to any view just as you add a sheet, alert and fullScreenCover, by applying a systemNotification view modifier (preferably to the application root view).
State-based notifications take a boolean state binding and a view builder:
import SystemNotification
struct MyView: View {
@State
var isActive = false
var body: some View {
VStack {
Button("Show notification") {
isActive = true
}
}
.systemNotification(isActive: $isActive) {
Text("You can use any custom content view")
.padding()
}
}
}
Context-based notifications just take a SystemNotificationContext instance and can then show many different notifications with a single modifier:
import SystemNotification
struct MyView: View {
@StateObject
var notification = SystemNotificationContext()
var body: some View {
VStack {
Button("Show text") {
notification.present {
Text("Context-based notifications are more flexible.")
.padding()
.multilineTextAlignment(.center)
}
}
Button("Show message") {
notification.present {
SystemNotificationMessage(
icon: Text("👍"),
title: "Great job!",
text: "You presented a native-looking message!"
)
}
}
}
.systemNotification(notification)
}
}
The SystemNotificationMessage view lets you easily mimic a native notification view, with an icon, title and text, but you can use any custom view as the notification body.
See the online getting started guide for more information.
Documentation
The online documentation has more information, articles, code examples, etc.
Demo Application
The Demo folder has an app that lets you explore the library.
Support My Work
You can become a sponsor to help me dedicate more time on my various open-source tools. Every contribution, no matter the size, makes a real difference in keeping these tools free and actively developed.
Contact
Feel free to reach out if you have questions, or want to contribute in any way:
- Website: danielsaidi.com
- E-mail: daniel.saidi@gmail.com
- Bluesky: @danielsaidi@bsky.social
- Mastodon: @danielsaidi@mastodon.social
License
SystemNotification is available under the MIT license. See the LICENSE file for more info.
Related Skills
node-connect
345.4kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
104.6kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
345.4kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
345.4kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
