-
-
Notifications
You must be signed in to change notification settings - Fork 466
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #353 from jonasrichardrichter/main
Permission - Add requesting for specific notification types
- Loading branch information
Showing
3 changed files
with
73 additions
and
8 deletions.
There are no files selected for viewing
42 changes: 42 additions & 0 deletions
42
Sources/NotificationPermission/NotificationAccess+userNotifcationAuthorizationOptions.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// | ||
// NotificationAccess+userNotifcationAuthorizationOptions.swift | ||
// | ||
// | ||
// Created by Jonas Richard Richter on 18.06.24. | ||
// | ||
|
||
import PermissionsKit | ||
import UserNotifications | ||
|
||
extension Permission.NotificationAccess { | ||
var userNotifcationAuthorizationOptions: UNAuthorizationOptions { | ||
switch self { | ||
case .badge: | ||
.badge | ||
case .sound: | ||
.sound | ||
case .alert: | ||
.alert | ||
case .carPlay: | ||
.carPlay | ||
case .criticalAlert: | ||
.criticalAlert | ||
case .providesAppNotificationSettings: | ||
.providesAppNotificationSettings | ||
case .provisional: | ||
.provisional | ||
case .announcement: | ||
if #available(iOS 13.0, watchOS 6.0, *) { | ||
.announcement | ||
} else { | ||
.alert | ||
} | ||
case .timeSensitive: | ||
if #available(iOS 15.0, tvOS 15.0, watchOS 8.0, *) { | ||
.timeSensitive | ||
} else { | ||
.alert | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters