forked from trustwallet/trust-wallet-ios
-
Notifications
You must be signed in to change notification settings - Fork 0
/
AppDelegate.swift
84 lines (69 loc) · 3.34 KB
/
AppDelegate.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
// Copyright DApps Platform Inc. All rights reserved.
import UIKit
import Branch
import RealmSwift
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate, UISplitViewControllerDelegate {
var window: UIWindow?
var coordinator: AppCoordinator!
//This is separate coordinator for the protection of the sensitive information.
lazy var protectionCoordinator: ProtectionCoordinator = {
return ProtectionCoordinator()
}()
let urlNavigatorCoordinator = URLNavigatorCoordinator()
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
window = UIWindow(frame: UIScreen.main.bounds)
let sharedMigration = SharedMigrationInitializer()
sharedMigration.perform()
let realm = try! Realm(configuration: sharedMigration.config)
let walletStorage = WalletStorage(realm: realm)
let keystore = EtherKeystore(storage: walletStorage)
coordinator = AppCoordinator(window: window!, keystore: keystore, navigator: urlNavigatorCoordinator)
coordinator.start()
if !UIApplication.shared.isProtectedDataAvailable {
fatalError()
}
protectionCoordinator.didFinishLaunchingWithOptions()
urlNavigatorCoordinator.branch.didFinishLaunchingWithOptions(launchOptions: launchOptions)
return true
}
func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
coordinator.didRegisterForRemoteNotificationsWithDeviceToken(deviceToken: deviceToken)
}
func applicationWillResignActive(_ application: UIApplication) {
protectionCoordinator.applicationWillResignActive()
Lock().setAutoLockTime()
CookiesStore.save()
}
func applicationDidBecomeActive(_ application: UIApplication) {
protectionCoordinator.applicationDidBecomeActive()
CookiesStore.load()
}
func applicationDidEnterBackground(_ application: UIApplication) {
protectionCoordinator.applicationDidEnterBackground()
}
func applicationWillEnterForeground(_ application: UIApplication) {
protectionCoordinator.applicationWillEnterForeground()
}
func application(_ application: UIApplication, shouldAllowExtensionPointIdentifier extensionPointIdentifier: UIApplicationExtensionPointIdentifier) -> Bool {
if extensionPointIdentifier == UIApplicationExtensionPointIdentifier.keyboard {
return false
}
return true
}
// func application(
// _ application: UIApplication,
// didReceiveRemoteNotification userInfo: [AnyHashable: Any],
// fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
// Branch.getInstance().handlePushNotification(userInfo)
// }
// Respond to URI scheme links
func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey: Any] = [:]) -> Bool {
return urlNavigatorCoordinator.application(app, open: url, options: options)
}
// Respond to Universal Links
func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([Any]?) -> Void) -> Bool {
Branch.getInstance().continue(userActivity)
return true
}
}