DHBW-Service-App/DHBW-Service/App/DHBW_ServiceApp.swift
Patrick Müller 02cd3a0db9 RaPla parser is now aware of recurring events
- Also some small improvements and basic implementation of Notifications
2021-04-07 13:26:37 +02:00

43 lines
1.4 KiB
Swift

//
// DHBW_ServiceApp.swift
// DHBW-Service
//
// Created by Patrick Müller on 20.12.20.
//
import SwiftUI
import UserNotifications
@main
struct DHBW_ServiceApp: App {
@UIApplicationDelegateAdaptor private var appDelegate: AppDelegate
let persistenceController = PersistenceController.shared
let settings = LocalSettings()
var body: some Scene {
WindowGroup {
ContentView()
.environment(\.managedObjectContext, persistenceController.context)
.environmentObject(settings)
}
}
}
//*** 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)
}
}