* ios: notifications service extension * create notifications in NSE (WIP) * refactor notifications to use in NSE * prepend team ID to shared defaults name to silence the warning * remove whitespace
46 lines
1.2 KiB
Swift
46 lines
1.2 KiB
Swift
//
|
|
// SimpleXApp.swift
|
|
// Shared
|
|
//
|
|
// Created by Evgeny Poberezkin on 17/01/2022.
|
|
//
|
|
|
|
import SwiftUI
|
|
import OSLog
|
|
|
|
let logger = Logger()
|
|
|
|
@main
|
|
struct SimpleXApp: App {
|
|
@UIApplicationDelegateAdaptor(AppDelegate.self) var appDelegate
|
|
@StateObject private var chatModel = ChatModel.shared
|
|
@Environment(\.scenePhase) var scenePhase
|
|
|
|
init() {
|
|
hs_init(0, nil)
|
|
BGManager.shared.register()
|
|
NtfManager.shared.registerCategories()
|
|
}
|
|
|
|
var body: some Scene {
|
|
return WindowGroup {
|
|
ContentView()
|
|
.environmentObject(chatModel)
|
|
.onOpenURL { url in
|
|
logger.debug("ContentView.onOpenURL: \(url)")
|
|
chatModel.appOpenUrl = url
|
|
}
|
|
.onAppear() {
|
|
initializeChat()
|
|
}
|
|
.onChange(of: scenePhase) { phase in
|
|
logger.debug("scenePhase \(String(describing: scenePhase))")
|
|
setAppState(phase)
|
|
if phase == .background {
|
|
BGManager.shared.schedule()
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|