mirror of
https://github.com/Mueller-Patrick/DHBW-Service-App.git
synced 2024-11-01 00:43:58 +00:00
43 lines
1.4 KiB
Swift
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)
|
|
}
|
|
}
|