Skip to content

Commit

Permalink
Updated doc for permissions accesses.
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanvorobei committed Nov 18, 2024
1 parent 80a04a4 commit 5e59359
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 6 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

}
```

Expand Down
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
4 changes: 3 additions & 1 deletion Sources/NotificationPermission/NotificationPermission.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,14 @@ import PermissionsKit
import UserNotifications

public extension Permission {
static func notification(access: Set<NotificationAccess> = [.alert, .badge, .sound]) -> NotificationPermission {

static func notification(_ access: Set<NotificationAccess> = [.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 }

Expand Down
1 change: 1 addition & 0 deletions Sources/PermissionsKit/Permission.swift
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ open class Permission {
}

public enum NotificationAccess {

case badge
case sound
case alert
Expand Down

0 comments on commit 5e59359

Please sign in to comment.