Add notification action to copy OTP or just inform about the copied OTP (#513)
* Add notification action to copy OTP or just inform about the copied OTP The notification either shows the current OTP which can be copied by a notification action or it shows just a hint to inform about the copied OTP. This depends on the new option "autoCopyOTP". * Extract method * Set type and style one-time
This commit is contained in:
parent
63e7235978
commit
e1cbcb5d7a
11 changed files with 155 additions and 76 deletions
|
|
@ -80,8 +80,26 @@ class PasswordNavigationViewController: UIViewController {
|
|||
}
|
||||
|
||||
private func requestNotificationPermission() {
|
||||
// Ask for permission to receive notifications
|
||||
let notificationCenter = UNUserNotificationCenter.current()
|
||||
let permissionOptions = UNAuthorizationOptions(arrayLiteral: .alert)
|
||||
UNUserNotificationCenter.current().requestAuthorization(options: permissionOptions) { _, _ in }
|
||||
notificationCenter.requestAuthorization(options: permissionOptions) { _, _ in }
|
||||
|
||||
// Register notification action
|
||||
let copyAction = UNNotificationAction(
|
||||
identifier: Globals.otpNotificationCopyAction,
|
||||
title: "CopyToPasteboard".localize(),
|
||||
options: UNNotificationActionOptions(rawValue: 0)
|
||||
)
|
||||
let otpCategory = UNNotificationCategory(
|
||||
identifier: Globals.otpNotificationCategory,
|
||||
actions: [copyAction],
|
||||
intentIdentifiers: [],
|
||||
hiddenPreviewsBodyPlaceholder: "",
|
||||
options: []
|
||||
)
|
||||
notificationCenter.setNotificationCategories([otpCategory])
|
||||
notificationCenter.delegate = NotificationCenterDispatcher.shared
|
||||
}
|
||||
|
||||
override func viewWillAppear(_ animated: Bool) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue