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
|
|
@ -70,22 +70,4 @@ public enum Utils {
|
|||
return passphrase
|
||||
}
|
||||
}
|
||||
|
||||
public static func showNotificationWithOTP(password: Password) {
|
||||
guard let otp = password.currentOtp else {
|
||||
return
|
||||
}
|
||||
let notificationCenter = UNUserNotificationCenter.current()
|
||||
notificationCenter.getNotificationSettings { state in
|
||||
guard state.authorizationStatus == .authorized else {
|
||||
return
|
||||
}
|
||||
let content = UNMutableNotificationContent()
|
||||
content.title = "OTPFor".localize(password.name)
|
||||
content.body = otp
|
||||
let trigger = UNTimeIntervalNotificationTrigger(timeInterval: 1, repeats: false)
|
||||
let request = UNNotificationRequest(identifier: "otpNotification", content: content, trigger: trigger)
|
||||
notificationCenter.add(request)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue