|
@@ -59,12 +59,6 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
|
|
|
|
|
|
private var privacyProtectionWindow: UIWindow?
|
|
|
|
|
|
- struct PushNotificationData {
|
|
|
- var account: String
|
|
|
- var json: [String: AnyObject]
|
|
|
- }
|
|
|
- var pushNotificationData: PushNotificationData = PushNotificationData(account: "", json: [:])
|
|
|
-
|
|
|
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
|
|
|
|
|
|
NCSettingsBundleHelper.checkAndExecuteSettings(delay: 0)
|
|
@@ -205,12 +199,18 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
|
|
|
NextcloudKit.shared.nkCommonInstance.writeLog("[INFO] Initialize Auto upload with \(items) uploads")
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ if let pref = UserDefaults.init(suiteName: NCBrandOptions.shared.capabilitiesGroups),
|
|
|
+ let data = pref.object(forKey: "NOTIFICATION_DATA") as? [String: AnyObject] {
|
|
|
+ nextcloudPushNotificationAction(data: data)
|
|
|
+ pref.set(nil, forKey: "NOTIFICATION_DATA")
|
|
|
+ }
|
|
|
+
|
|
|
NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterApplicationDidBecomeActive)
|
|
|
}
|
|
|
|
|
|
|
|
|
func applicationWillEnterForeground(_ application: UIApplication) {
|
|
|
- NCApplicationHandle().applicationWillEnterForeground(application)
|
|
|
guard !account.isEmpty, let activeAccount = NCManageDatabase.shared.getActiveAccount() else { return }
|
|
|
|
|
|
NextcloudKit.shared.nkCommonInstance.writeLog("[INFO] Application will enter in foreground")
|
|
@@ -409,25 +409,6 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
|
|
|
|
|
|
|
|
|
func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
|
|
|
- do {
|
|
|
- let userInfo = notification.request.content.userInfo
|
|
|
- if let message = userInfo["subject"] as? String {
|
|
|
- let tableAccounts = NCManageDatabase.shared.getAllAccount()
|
|
|
- for tableAccount in tableAccounts {
|
|
|
- guard let privateKey = CCUtility.getPushNotificationPrivateKey(tableAccount.account),
|
|
|
- let decryptedMessage = NCPushNotificationEncryption.shared().decryptPushNotification(message, withDevicePrivateKey: privateKey),
|
|
|
- let data = decryptedMessage.data(using: .utf8) else {
|
|
|
- continue
|
|
|
- }
|
|
|
- if let json = try JSONSerialization.jsonObject(with: data) as? [String: AnyObject] {
|
|
|
- pushNotificationData = PushNotificationData(account: tableAccount.account, json: json)
|
|
|
- print(json)
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- } catch let error as NSError {
|
|
|
- print("Failed : \(error.localizedDescription)")
|
|
|
- }
|
|
|
completionHandler([.list, .banner, .sound])
|
|
|
}
|
|
|
|
|
@@ -449,6 +430,10 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ func nextcloudPushNotificationAction(data: [String: AnyObject]) {
|
|
|
+ NCApplicationHandle().nextcloudPushNotificationAction(data: data)
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
|
|
|
@objc func openLogin(viewController: UIViewController?, selector: Int, openLoginWeb: Bool) {
|