Skip to content

Commit 3eea063

Browse files
authored
Fix issues with OTP notification (#517)
* Use "Beta" since this is what Apple uses too * Actually copy the OTP if the option is set * Shorten notification text to make it fit to smaller screens * Set notification center delegate before app launches * Fix SwiftFormat issue fixed with version 0.48.12
1 parent 32b7c9b commit 3eea063

File tree

7 files changed

+11
-10
lines changed

7 files changed

+11
-10
lines changed

pass/AppDelegate.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
3434
perform(#selector(postSearchNotification), with: nil, afterDelay: 0.4)
3535
}
3636
}
37+
UNUserNotificationCenter.current().delegate = NotificationCenterDispatcher.shared
3738
return true
3839
}
3940

pass/Controllers/PasswordNavigationViewController.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@ class PasswordNavigationViewController: UIViewController {
9999
options: []
100100
)
101101
notificationCenter.setNotificationCategories([otpCategory])
102-
notificationCenter.delegate = NotificationCenterDispatcher.shared
103102
}
104103

105104
override func viewWillAppear(_ animated: Bool) {

pass/Controllers/SettingsTableViewController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ class SettingsTableViewController: UITableViewController, UITabBarControllerDele
225225
@objc
226226
func alertTextFieldDidChange(_ sender: UITextField) {
227227
// check whether we should enable the Save button in setPasscodeLockAlert
228-
if let setPasscodeLockAlert = self.setPasscodeLockAlert,
228+
if let setPasscodeLockAlert = setPasscodeLockAlert,
229229
let setPasscodeLockAlertTextFields0 = setPasscodeLockAlert.textFields?[0],
230230
let setPasscodeLockAlertTextFields1 = setPasscodeLockAlert.textFields?[1] {
231231
if sender == setPasscodeLockAlertTextFields0 || sender == setPasscodeLockAlertTextFields1 {

pass/de.lproj/Localizable.strings

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@
2323
"None" = "Kein valides Token";
2424
"ExpiresIn" = "(läuft in %ds ab)";
2525
"OTPForPassword" = "Einmalpasswort für %@";
26-
"OTPForPasswordCopied" = "Einmalpasswort für %@ kopiert";
26+
"OTPHasBeenCopied" = "... wurde in die Zwischenablage kopiert";
2727
"CopyToPasteboard" = "In Zwischenablage kopieren";
2828
"AutoCopyOTP" = "OTPs automatisch kopieren";
29-
"AutoCopyOTPExplanation." = "Nachdem Login und Passwort automatisch in die vorgesehenen Felder gefüllt wurden, wird eine Benachrichtigung mit dem aktuellen Einmalpasswort angezeigt. Dieses kann in die Zwischenablage kopiert werden. Ist diese Option aktiviert, geschieht das Kopieren automatisch.";
29+
"AutoCopyOTPExplanation." = "Nachdem Login und Passwort automatisch in die vorgesehenen Felder eingefügt wurden, wird eine Benachrichtigung mit dem aktuellen Einmalpasswort angezeigt. Dieses kann in die Zwischenablage kopiert werden. Ist diese Option aktiviert, geschieht das Kopieren automatisch.";
3030

3131
// General (error) messages
3232
"Error" = "Fehler";
@@ -46,7 +46,7 @@
4646
"PasswordGeneratorFlavor" = "Art";
4747
"RememberPgpKeyPassphrase" = "GPG-Schlüssel-Passwort merken";
4848
"RememberGitCredentialPassphrase" = "Git-Server-Passwort merken";
49-
"EnableGPGID" = "Berücksichtige .gpg-id Dateien (experimentell)";
49+
"EnableGPGID" = "Berücksichtige .gpg-id Dateien (Beta)";
5050
"ShowFolders" = "Ordner anzeigen";
5151
"HidePasswordImages" = "Favicons verstecken";
5252
"HidePasswordImagesExplanation." = "Favicons werden basierend auf der assoziierten URL geladen und in Passworteinträgen angezeigt. Aktiviere diese Option, um das Laden dieser Bilder zu unterbinden und sie nicht anzuzeigen.";

pass/en.lproj/Localizable.strings

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"None" = "None";
2424
"ExpiresIn" = "(expires in %ds)";
2525
"OTPForPassword" = "One-time password for %@";
26-
"OTPForPasswordCopied" = "One-time password for %@ copied";
26+
"OTPHasBeenCopied" = "... has been copied to the pasteboard";
2727
"CopyToPasteboard" = "Copy to pasteboard";
2828
"AutoCopyOTP" = "Automatically Copy OTPs";
2929
"AutoCopyOTPExplanation." = "After username and password have been auto-filled into a form by Pass, a notification is shown with the current one-time password which can be copied to the pasteboard. Enabling this option automatically copies the current one-time password.";
@@ -46,7 +46,7 @@
4646
"PasswordGeneratorFlavor" = "Style";
4747
"RememberPgpKeyPassphrase" = "Remember PGP Key Passphrase";
4848
"RememberGitCredentialPassphrase" = "Remember Git Credential Passphrase";
49-
"EnableGPGID" = "Enable .gpg-id (Experiment)";
49+
"EnableGPGID" = "Enable .gpg-id (Beta)";
5050
"ShowFolders" = "Show Folders";
5151
"HidePasswordImages" = "Hide Password Images";
5252
"HidePasswordImagesExplanation." = "Associated favicon images are loaded and shown based upon the URL associated with an entry. Enable this option to hide these images and prevent them from being loaded.";

passKit/Helpers/NotificationCenterDispatcher.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,11 @@ public class NotificationCenterDispatcher: NSObject, UNUserNotificationCenterDel
2828
return
2929
}
3030
let content = UNMutableNotificationContent()
31+
content.title = "OTPForPassword".localize(password.name)
3132
if Defaults.autoCopyOTP {
32-
content.title = "OTPForPasswordCopied".localize(password.name)
33+
content.body = "OTPHasBeenCopied".localize()
34+
UIPasteboard.general.string = otp
3335
} else {
34-
content.title = "OTPForPassword".localize(password.name)
3536
content.body = otp
3637
content.categoryIdentifier = Globals.otpNotificationCategory
3738
content.userInfo = [

passKit/Parser/Parser.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class Parser {
1717
init(plainText: String) {
1818
let splittedPlainText = plainText.splitByNewline()
1919

20-
firstLine = splittedPlainText.first!
20+
self.firstLine = splittedPlainText.first!
2121
self.additionsSection = splittedPlainText[1...].joined(separator: "\n")
2222
self.purgedAdditionalLines = splittedPlainText[1...].filter { !$0.isEmpty }
2323
}

0 commit comments

Comments
 (0)