Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanvorobei committed Sep 28, 2019
2 parents 50098e1 + 0fbec63 commit 42f62b9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,16 @@ extension SPPermission {
controller.present(on: viewController)
}
}

public static func requestIfNeeded(with permissions: [SPPermissionType], on viewController: UIViewController, delegate: SPPermissionDialogDelegate? = nil, dataSource: SPPermissionDialogDataSource? = nil) {

request(
with: permissions.filter { SPPermission.isAllowed($0) == false },
on: viewController,
delegate: delegate,
dataSource: dataSource
)
}
}
}

Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,11 @@ class ViewController: UIViewController {
}
```

If you want to request permission only when permission is needed, you can use `requestIfNeeded()`
```swift
SPPermission.Dialog.requestIfNeeded(with: [.camera, .microphone, .notification], on:self)
```

If you want to know if permission is allowed, you need to call the function:

```swift
Expand Down

0 comments on commit 42f62b9

Please sign in to comment.