B. Petersen 2 년 전
부모
커밋
e4d7f548f2
2개의 변경된 파일34개의 추가작업 그리고 10개의 파일을 삭제
  1. 32 10
      deltachat-ios/Controller/Settings/SettingsViewController.swift
  2. 2 0
      deltachat-ios/Info.plist

+ 32 - 10
deltachat-ios/Controller/Settings/SettingsViewController.swift

@@ -1,6 +1,7 @@
 import UIKit
 import UIKit
 import DcCore
 import DcCore
 import Intents
 import Intents
+import LocalAuthentication
 
 
 internal final class SettingsViewController: UITableViewController {
 internal final class SettingsViewController: UITableViewController {
 
 
@@ -267,17 +268,38 @@ internal final class SettingsViewController: UITableViewController {
     }
     }
 
 
     private func showBackupProviderViewController() {
     private func showBackupProviderViewController() {
-        let alert = UIAlertController(title: String.localized("multidevice_title"), message: String.localized("multidevice_this_creates_a_qr_code"), preferredStyle: .alert)
-        alert.addAction(UIAlertAction(title: String.localized("cancel"), style: .cancel, handler: nil))
-        alert.addAction(UIAlertAction(
-            title: String.localized("perm_continue"),
-            style: .default,
-            handler: { [weak self] _ in
-                guard let self = self else { return }
-                self.navigationController?.pushViewController(BackupTransferViewController(dcAccounts: self.dcAccounts), animated: true)
+        let context = LAContext()
+        var error: NSError?
+
+        if context.canEvaluatePolicy(.deviceOwnerAuthentication, error: &error) {
+            // authentication available
+            let reason = String.localized("multidevice_this_creates_a_qr_code")
+            context.evaluatePolicy(.deviceOwnerAuthentication, localizedReason: reason) { [weak self] success, cauthenticationError in
+                DispatchQueue.main.async {
+                    guard let self = self else { return }
+                    if success {
+                        self.navigationController?.pushViewController(BackupTransferViewController(dcAccounts: self.dcAccounts), animated: true)
+                    } else {
+                        let alert = UIAlertController(title: nil, message: "Authentication failed, please try again.", preferredStyle: .alert)
+                        alert.addAction(UIAlertAction(title: String.localized("ok"), style: .default, handler: nil))
+                        self.present(alert, animated: true)
+                    }
+                }
             }
             }
-        ))
-        present(alert, animated: true)
+        } else {
+            // no authentication available
+            let alert = UIAlertController(title: String.localized("multidevice_title"), message: String.localized("multidevice_this_creates_a_qr_code"), preferredStyle: .alert)
+            alert.addAction(UIAlertAction(title: String.localized("cancel"), style: .cancel, handler: nil))
+            alert.addAction(UIAlertAction(
+                title: String.localized("perm_continue"),
+                style: .default,
+                handler: { [weak self] _ in
+                    guard let self = self else { return }
+                    self.navigationController?.pushViewController(BackupTransferViewController(dcAccounts: self.dcAccounts), animated: true)
+                }
+            ))
+            present(alert, animated: true)
+        }
     }
     }
 
 
     private func showAdvanced() {
     private func showAdvanced() {

+ 2 - 0
deltachat-ios/Info.plist

@@ -106,6 +106,8 @@
 		<string>UIInterfaceOrientationLandscapeLeft</string>
 		<string>UIInterfaceOrientationLandscapeLeft</string>
 		<string>UIInterfaceOrientationLandscapeRight</string>
 		<string>UIInterfaceOrientationLandscapeRight</string>
 	</array>
 	</array>
+	<key>NSFaceIDUsageDescription</key>
+	<string>Creates a QR code that the second device can scan to copy the account</string>
 	<key>ITSAppUsesNonExemptEncryption</key>
 	<key>ITSAppUsesNonExemptEncryption</key>
 	<false/>
 	<false/>
 </dict>
 </dict>