diff --git a/README.md b/README.md index 1f2d33cb..3752aa6b 100644 --- a/README.md +++ b/README.md @@ -137,8 +137,8 @@ If you put all your code into one package and compile it, the Apple Review Team import PermissionsKit import NotificationPermission -Permission.notification.request { - +PermissionsKit.Permission.notification([.alert, .badge, .sound]).request { + } ``` diff --git a/Sources/NotificationPermission/NotificationAccess+userNotifcationAuthorizationOptions.swift b/Sources/NotificationPermission/NotificationAccess+userNotifcationAuthorizationOptions.swift index 650cde79..cbb90269 100644 --- a/Sources/NotificationPermission/NotificationAccess+userNotifcationAuthorizationOptions.swift +++ b/Sources/NotificationPermission/NotificationAccess+userNotifcationAuthorizationOptions.swift @@ -1,14 +1,29 @@ +// The MIT License (MIT) +// Copyright © 2022 Sparrow Code LTD (https://sparrowcode.io, hello@sparrowcode.io) // -// NotificationAccess+userNotifcationAuthorizationOptions.swift +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: // +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. // -// Created by Jonas Richard Richter on 18.06.24. -// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. import PermissionsKit import UserNotifications extension Permission.NotificationAccess { + var userNotifcationAuthorizationOptions: UNAuthorizationOptions { switch self { case .badge: diff --git a/Sources/NotificationPermission/NotificationPermission.swift b/Sources/NotificationPermission/NotificationPermission.swift index 95bb40a6..b9cc7782 100644 --- a/Sources/NotificationPermission/NotificationPermission.swift +++ b/Sources/NotificationPermission/NotificationPermission.swift @@ -27,12 +27,14 @@ import PermissionsKit import UserNotifications public extension Permission { - static func notification(access: Set = [.alert, .badge, .sound]) -> NotificationPermission { + + static func notification(_ access: Set = [.alert, .badge, .sound]) -> NotificationPermission { return NotificationPermission(kind: .notification(access: access)) } } public class NotificationPermission: Permission { + private var _kind: Permission.Kind open override var kind: Permission.Kind { self._kind } diff --git a/Sources/PermissionsKit/Permission.swift b/Sources/PermissionsKit/Permission.swift index 0c0dee62..cb50d2df 100644 --- a/Sources/PermissionsKit/Permission.swift +++ b/Sources/PermissionsKit/Permission.swift @@ -179,6 +179,7 @@ open class Permission { } public enum NotificationAccess { + case badge case sound case alert