2020-12-19 23:36:41 +00:00
|
|
|
//
|
|
|
|
// DHBW_ServiceApp.swift
|
|
|
|
// DHBW-Service
|
|
|
|
//
|
|
|
|
// Created by Patrick Müller on 20.12.20.
|
|
|
|
//
|
|
|
|
|
|
|
|
import SwiftUI
|
2021-04-07 11:26:37 +00:00
|
|
|
import UserNotifications
|
2020-12-19 23:36:41 +00:00
|
|
|
|
|
|
|
@main
|
|
|
|
struct DHBW_ServiceApp: App {
|
2021-04-07 11:26:37 +00:00
|
|
|
@UIApplicationDelegateAdaptor private var appDelegate: AppDelegate
|
2020-12-19 23:36:41 +00:00
|
|
|
let persistenceController = PersistenceController.shared
|
2020-12-21 19:54:59 +00:00
|
|
|
let settings = LocalSettings()
|
2021-04-07 11:26:37 +00:00
|
|
|
|
2020-12-19 23:36:41 +00:00
|
|
|
var body: some Scene {
|
|
|
|
WindowGroup {
|
|
|
|
ContentView()
|
2020-12-21 19:28:01 +00:00
|
|
|
.environment(\.managedObjectContext, persistenceController.context)
|
2020-12-21 19:54:59 +00:00
|
|
|
.environmentObject(settings)
|
2020-12-19 23:36:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-04-07 11:26:37 +00:00
|
|
|
|
|
|
|
//*** Implement App delegate ***//
|
|
|
|
class AppDelegate: NSObject, UIApplicationDelegate {
|
|
|
|
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
|
|
|
//No callback in simulator
|
|
|
|
//-- must use device to get valid push token
|
|
|
|
func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
|
|
|
|
let tokenParts = deviceToken.map { data in String(format: "%02.2hhx", data) }
|
|
|
|
let token = tokenParts.joined()
|
|
|
|
print("Device Token: \(token)")
|
|
|
|
}
|
|
|
|
func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Error) {
|
|
|
|
print(error.localizedDescription)
|
|
|
|
}
|
|
|
|
}
|