AutoCat/AutoCat/AppDelegate.swift
Selim Mustafaev f513222d72 Voice recording fixes.
Adding experimental siri support
2020-06-28 20:30:28 +03:00

82 lines
2.8 KiB
Swift

import UIKit
import RealmSwift
import RxSwift
import RxCocoa
import os.log
extension OSLog {
static let startup = OSLog(subsystem: "pro.aliencat.autocat.startup", category: "startup")
}
enum QuickAction {
case none
case check
case checkNumber(String)
case addVoiceRecord
}
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var quickAction: QuickAction = .none
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
let config = Realm.Configuration(
schemaVersion: 9,
migrationBlock: { migration, oldSchemaVersion in
if oldSchemaVersion <= 3 {
var numbers: [String] = []
migration.enumerateObjects(ofType: "Vehicle") { old, new in
if let number = old?["number"] as? String {
if numbers.contains(number) {
migration.delete(old!)
} else {
numbers.append(number)
}
}
}
}
})
Realm.Configuration.defaultConfiguration = config
IHProgressHUD.set(defaultStyle: .dark)
IHProgressHUD.set(defaultMaskType: .black)
Logging.URLRequests = { _ in false };
return true
}
// MARK: UISceneSession Lifecycle
func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration {
// Called when a new scene session is being created.
// Use this method to select a configuration to create the new scene with.
#if !targetEnvironment(macCatalyst)
if let shortcutItem = options.shortcutItem {
if shortcutItem.type == "CheckNumberAction" {
self.quickAction = .check
} else if shortcutItem.type == "AddVoiceRecordAction" {
self.quickAction = .addVoiceRecord
}
}
#endif
return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role)
}
func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set<UISceneSession>) {
// Called when the user discards a scene session.
// If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions.
// Use this method to release any resources that were specific to the discarded scenes, as they will not return.
}
}