Show notification with OTP after providing password through extension (#509)
* Allow to do something with a password after providing it in the extension * Make fields non-nil * Show OTP in notification after providing a password through extension
This commit is contained in:
parent
5057528ad9
commit
763cddf540
9 changed files with 67 additions and 69 deletions
|
|
@ -70,4 +70,22 @@ 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