瀏覽代碼

register for `dcaccount:` scheme

Simon Laux 2 年之前
父節點
當前提交
2ccd0594d4
共有 4 個文件被更改,包括 24 次插入2 次删除
  1. 1 0
      CHANGELOG.md
  2. 6 0
      deltachat-ios/AppDelegate.swift
  3. 16 2
      deltachat-ios/Controller/WelcomeViewController.swift
  4. 1 0
      deltachat-ios/Info.plist

+ 1 - 0
CHANGELOG.md

@@ -13,6 +13,7 @@
 * fix accessibility hint in multi-select chat list title
 * update translations, revise english source
 * update to core90
+* register on system for `dcaccount:` scheme
 
 
 ## v1.31.0 Testflight

+ 6 - 0
deltachat-ios/AppDelegate.swift

@@ -174,6 +174,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
         appFullyInitialized = true
     }
 
+    public var accountCreationQrCode: String = ""
     // `open` is called when an url should be opened by Delta Chat.
     // we currently use that for handling oauth2 and for handing openpgp4fpr.
     //
@@ -187,6 +188,11 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
         // }
 
         switch url.scheme?.lowercased() {
+        case "dcaccount":
+            _ = self.dcAccounts.add()
+            accountCreationQrCode = url.absoluteString
+            reloadDcContext()
+            return true
         case "openpgp4fpr":
             // Hack to format url properly
             let urlString = url.absoluteString

+ 16 - 2
deltachat-ios/Controller/WelcomeViewController.swift

@@ -59,7 +59,7 @@ class WelcomeViewController: UIViewController, ProgressAlertHandler {
 
     private var qrCodeReader: QrCodeReaderController?
     weak var progressAlert: UIAlertController?
-
+    
     init(dcAccounts: DcAccounts) {
         self.dcAccounts = dcAccounts
         self.dcContext = dcAccounts.getSelected()
@@ -90,6 +90,16 @@ class WelcomeViewController: UIViewController, ProgressAlertHandler {
         }
         navigationItem.rightBarButtonItem = moreButton
     }
+    
+    override func viewDidAppear(_ animated: Bool) {
+        if let appDelegate = UIApplication.shared.delegate as? AppDelegate {
+            if !appDelegate.accountCreationQrCode.isEmpty {
+                self.handleQrCode(appDelegate.accountCreationQrCode)
+            }
+            appDelegate.accountCreationQrCode = ""
+        }
+        super.viewDidAppear(animated)
+    }
 
     override func viewDidLayoutSubviews() {
         super.viewDidLayoutSubviews()
@@ -339,7 +349,11 @@ extension WelcomeViewController: QrCodeReaderDelegate {
 
         alert.addAction(okAction)
         alert.addAction(qrCancelAction)
-        qrCodeReader?.present(alert, animated: true)
+        if qrCodeReader != nil {
+            qrCodeReader?.present(alert, animated: true)
+        } else {
+            self.present(alert, animated: true)
+        }
     }
 
     private func qrErrorAlert() {

+ 1 - 0
deltachat-ios/Info.plist

@@ -29,6 +29,7 @@
 			<array>
 				<string>chat.delta</string>
 				<string>openpgp4fpr</string>
+				<string>dcaccount</string>
 			</array>
 		</dict>
 		<dict>