taler-ios

iOS apps for GNU Taler (wallet)
Log | Files | Refs | README | LICENSE

AppDelegate.swift (1763B)


      1 /*
      2  * This file is part of GNU Taler, ©2022-26 Taler Systems S.A.
      3  * See LICENSE.md
      4  */
      5 /**
      6  * AppDelegate
      7  *
      8  * @author Marc Stibane
      9  */
     10 import SwiftUI
     11 import SymLog
     12 
     13 class AppDelegate: NSObject, UIApplicationDelegate {
     14     private let symLog = SymLogC()
     15 
     16     func application(_ application: UIApplication,
     17                      didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil
     18     ) -> Bool {
     19 //        @AppStorage("pushNotifications") var pushNotifications: Bool = false
     20 
     21         symLog.log("App has launched successfully!")
     22         return true
     23     }
     24 
     25     func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
     26         let tokenString = deviceToken.hexEncodedString()
     27         symLog.log("deviceToken: \(tokenString)")
     28         Controller.shared.deviceTokenAPNs = tokenString
     29         // TODO: tell walletCore
     30     }
     31     func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Error) {
     32         symLog.log("Failed to register for remote notifications with error: \(error)")
     33         // TODO: tell the user...
     34     }
     35 
     36     func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable: Any],
     37                      fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
     38         symLog.log(userInfo)
     39         // TODO: react on receiving a background notification
     40 //        guard let groupId = userInfo[PushNotificationKeys.groupId] as? String else {
     41 //            completionHandler(.noData)
     42 //            return
     43 //        }
     44 //        notificationsCenterService.removeDeliveredNotifications(groupId: groupId)
     45         completionHandler(.newData)
     46     }
     47 }