A SwiftUI package for elegant, customizable permission request sheets with animated previews for notifications and location services.
- 🎨 Beautiful pre-built permission request sheets
- 🔔 Support for Notification and Location permissions
- ✨ Animated native-looking preview screens
- 🎯 Customizable titles and descriptions
- ⚡️ Simple ViewModifier-based implementation
- 📱 iOS-style design that matches system UI
- 🔄 Configurable display frequency (immediate, once, etc.)
Add the following to your Package.swift
file:
dependencies: [
.package(url: "https://github.com/yourusername/PermissionSheets.git", from: "1.0.0")
]
Or add it directly in Xcode:
- Go to File > Add Packages
- Paste the repository URL
- Click Add Package
import SwiftUI
import PermissionSheets
struct ContentView: View {
var body: some View {
Text("Hello, World!")
.askNotificationPermission()
}
}
import SwiftUI
import PermissionSheets
struct ContentView: View {
var body: some View {
Text("Hello, World!")
.askLocationPermission()
}
}
Text("Hello, World!")
.askNotificationPermission(
config: PermissionConfig(
title: "Stay Updated!",
description: "Enable notifications to never miss important updates"
)
)
Control how often the permission sheet appears:
Text("Hello, World!")
.askLocationPermission(
config: PermissionConfig(
displayFrequency: .once,
title: "Location Access",
description: "We need your location to show nearby places"
)
)
Available display frequencies:
.immediate
: Shows every time.once
: Shows only once.daily
: Shows once per day.weekly
: Shows once per week
Force the permission sheet to show regardless of previous user interaction:
Text("Hello, World!")
.askNotificationPermission(
config: PermissionConfig(forceShow: true)
)
- iOS 16.0+
- Swift 5.5+
- SwiftUI 3.0+
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.
- Inspired by native iOS permission requests
- Built with SwiftUI
- Created with ❤️
[Aayush Pokharel]
- Twitter: @aayushbuilds
- GitHub: @Aayush9029