taler-ios

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

AppDelegate.swift (1684B)


      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                         // TODO: tell walletCore
     29     }
     30     func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Error) {
     31         symLog.log("Failed to register for remote notifications with error: \(error)")
     32     }
     33 
     34     func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable: Any],
     35                      fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
     36         symLog.log(userInfo)
     37 //        guard let groupId = userInfo[PushNotificationKeys.groupId] as? String else {
     38 //            completionHandler(.noData)
     39 //            return
     40 //        }
     41 //        notificationsCenterService.removeDeliveredNotifications(groupId: groupId)
     42         completionHandler(.newData)
     43 
     44     }
     45 }