From a73a4350981cae0cdf91576c166c2903a999b504 Mon Sep 17 00:00:00 2001 From: Marino Faggiana Date: Sun, 18 Jun 2023 13:49:00 +0200 Subject: [PATCH 1/9] coding --- ExternalResources/NCApplicationHandle.swift | 3 ++- iOSClient/AppDelegate.swift | 20 +++++++++++++++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/ExternalResources/NCApplicationHandle.swift b/ExternalResources/NCApplicationHandle.swift index d4f6750aff..1748f615d8 100644 --- a/ExternalResources/NCApplicationHandle.swift +++ b/ExternalResources/NCApplicationHandle.swift @@ -32,7 +32,8 @@ class NCApplicationHandle: NSObject { // class: AppDelegate // func nextcloudPushNotificationAction(data: [String: AnyObject]) - func nextcloudPushNotificationAction(data: [String: AnyObject]) { + func nextcloudPushNotificationAction(data: [String: AnyObject], completion: @escaping (_ detected: Bool) -> Void) { + completion(false) } // class: AppDelegate diff --git a/iOSClient/AppDelegate.swift b/iOSClient/AppDelegate.swift index 2692dc6db1..cb95075708 100644 --- a/iOSClient/AppDelegate.swift +++ b/iOSClient/AppDelegate.swift @@ -440,7 +440,25 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD } func nextcloudPushNotificationAction(data: [String: AnyObject]) { - NCApplicationHandle().nextcloudPushNotificationAction(data: data) + NCApplicationHandle().nextcloudPushNotificationAction(data: data) { detected in + if !detected { + let accounts = NCManageDatabase.shared.getAllAccount() + for account in accounts { + /* + let urlBase = URL(string: account.urlBase) + if url.contains(urlBase?.host ?? "") && userId == account.userId { + changeAccount(account.account) + return account + } + */ + } + if let viewController = UIStoryboard(name: "NCNotification", bundle: nil).instantiateInitialViewController() as? NCNotification { + let navigationController = UINavigationController(rootViewController: viewController) + navigationController.modalPresentationStyle = .fullScreen + self.window?.rootViewController?.present(navigationController, animated: true) + } + } + } } // MARK: - Login & checkErrorNetworking From 0a8a42aeebe5bd09158368c1f6b73e9e3bad8dfb Mon Sep 17 00:00:00 2001 From: Marino Faggiana Date: Mon, 19 Jun 2023 12:13:31 +0200 Subject: [PATCH 2/9] Update AppDelegate.swift --- iOSClient/AppDelegate.swift | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/iOSClient/AppDelegate.swift b/iOSClient/AppDelegate.swift index cb95075708..72e1d97d23 100644 --- a/iOSClient/AppDelegate.swift +++ b/iOSClient/AppDelegate.swift @@ -442,6 +442,13 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD func nextcloudPushNotificationAction(data: [String: AnyObject]) { NCApplicationHandle().nextcloudPushNotificationAction(data: data) { detected in if !detected { + + let json = "Converted successfully: \(data)" + let alertController = UIAlertController(title: "x", message: json, preferredStyle: .alert) + alertController.addAction(UIAlertAction(title: NSLocalizedString("_ok_", comment: ""), style: .default, handler: { action in })) + self.window?.rootViewController?.present(alertController, animated: true) + + /* let accounts = NCManageDatabase.shared.getAllAccount() for account in accounts { /* @@ -457,6 +464,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD navigationController.modalPresentationStyle = .fullScreen self.window?.rootViewController?.present(navigationController, animated: true) } + */ } } } From 7db91c6f8974d94f616d641b078a632355d4e9db Mon Sep 17 00:00:00 2001 From: Marino Faggiana Date: Mon, 19 Jun 2023 16:45:01 +0200 Subject: [PATCH 3/9] Update NCBrand.swift --- Brand/NCBrand.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Brand/NCBrand.swift b/Brand/NCBrand.swift index 98471e5db4..969b80614e 100755 --- a/Brand/NCBrand.swift +++ b/Brand/NCBrand.swift @@ -35,7 +35,7 @@ import UIKit @objc public var textCopyrightNextcloudiOS: String = "Nextcloud Liquid for iOS %@ © 2023" @objc public var textCopyrightNextcloudServer: String = "Nextcloud Server %@" @objc public var loginBaseUrl: String = "https://cloud.nextcloud.com" - @objc public var pushNotificationServerProxy: String = "https://push-notifications.nextcloud.com" + @objc public var pushNotificationServerProxy: String = "c0004.customerpush.nextcloud.com" @objc public var linkLoginHost: String = "https://nextcloud.com/install" @objc public var linkloginPreferredProviders: String = "https://nextcloud.com/signup-ios" @objc public var webLoginAutenticationProtocol: String = "nc://" // example "abc://" From 390102e8870caf317325353410daeaa39e1139dd Mon Sep 17 00:00:00 2001 From: Marino Faggiana Date: Thu, 6 Jul 2023 12:02:37 +0200 Subject: [PATCH 4/9] Update NCBrand.swift --- Brand/NCBrand.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Brand/NCBrand.swift b/Brand/NCBrand.swift index 969b80614e..2d89f5a50f 100755 --- a/Brand/NCBrand.swift +++ b/Brand/NCBrand.swift @@ -35,7 +35,7 @@ import UIKit @objc public var textCopyrightNextcloudiOS: String = "Nextcloud Liquid for iOS %@ © 2023" @objc public var textCopyrightNextcloudServer: String = "Nextcloud Server %@" @objc public var loginBaseUrl: String = "https://cloud.nextcloud.com" - @objc public var pushNotificationServerProxy: String = "c0004.customerpush.nextcloud.com" + @objc public var pushNotificationServerProxy: String = "https://c0004.customerpush.nextcloud.com" @objc public var linkLoginHost: String = "https://nextcloud.com/install" @objc public var linkloginPreferredProviders: String = "https://nextcloud.com/signup-ios" @objc public var webLoginAutenticationProtocol: String = "nc://" // example "abc://" From 0e437326f744d3d6f258eb6a60e792d28b70cee0 Mon Sep 17 00:00:00 2001 From: Marino Faggiana Date: Mon, 10 Jul 2023 15:16:31 +0200 Subject: [PATCH 5/9] detect twofactor_nextcloud_notification Signed-off-by: Marino Faggiana --- iOSClient/AppDelegate.swift | 42 +++++++++++++++++++------------------ iOSClient/NCGlobal.swift | 7 ++++--- 2 files changed, 26 insertions(+), 23 deletions(-) diff --git a/iOSClient/AppDelegate.swift b/iOSClient/AppDelegate.swift index 72e1d97d23..0acd2d9d82 100644 --- a/iOSClient/AppDelegate.swift +++ b/iOSClient/AppDelegate.swift @@ -443,28 +443,30 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD NCApplicationHandle().nextcloudPushNotificationAction(data: data) { detected in if !detected { - let json = "Converted successfully: \(data)" - let alertController = UIAlertController(title: "x", message: json, preferredStyle: .alert) - alertController.addAction(UIAlertAction(title: NSLocalizedString("_ok_", comment: ""), style: .default, handler: { action in })) - self.window?.rootViewController?.present(alertController, animated: true) - - /* - let accounts = NCManageDatabase.shared.getAllAccount() - for account in accounts { - /* - let urlBase = URL(string: account.urlBase) - if url.contains(urlBase?.host ?? "") && userId == account.userId { - changeAccount(account.account) - return account + var openNotification: Bool = false + + if let accountPush = data["account"] as? String, + let app = data["app"] as? String, + app == NCGlobal.shared.twofactorNotificatioName { + if accountPush == self.account { + openNotification = true + } else { + let accounts = NCManageDatabase.shared.getAllAccount() + for account in accounts { + if account.account == accountPush { + self.changeAccount(account.account) + openNotification = true + } + } + } + if openNotification, let viewController = UIStoryboard(name: "NCNotification", bundle: nil).instantiateInitialViewController() as? NCNotification { + DispatchQueue.main.asyncAfter(deadline: .now() + 1) { + let navigationController = UINavigationController(rootViewController: viewController) + navigationController.modalPresentationStyle = .fullScreen + self.window?.rootViewController?.present(navigationController, animated: true) + } } - */ - } - if let viewController = UIStoryboard(name: "NCNotification", bundle: nil).instantiateInitialViewController() as? NCNotification { - let navigationController = UINavigationController(rootViewController: viewController) - navigationController.modalPresentationStyle = .fullScreen - self.window?.rootViewController?.present(navigationController, animated: true) } - */ } } } diff --git a/iOSClient/NCGlobal.swift b/iOSClient/NCGlobal.swift index 6b4432a21a..6198a26f58 100644 --- a/iOSClient/NCGlobal.swift +++ b/iOSClient/NCGlobal.swift @@ -88,9 +88,10 @@ class NCGlobal: NSObject { // Name // - @objc let appName = "files" - @objc let talkName = "talk-message" - @objc let appScheme = "nextcloud" + let appName = "files" + let talkName = "talk-message" + let twofactorNotificatioName = "twofactor_nextcloud_notification" + let appScheme = "nextcloud" // Nextcloud version // From 5da8cc83ee2bdb699356f666e3e0887f8c04c9c9 Mon Sep 17 00:00:00 2001 From: Marino Faggiana Date: Mon, 10 Jul 2023 15:32:14 +0200 Subject: [PATCH 6/9] NCNotification Signed-off-by: Marino Faggiana --- iOSClient/NCGlobal.swift | 1 + iOSClient/Notification/NCNotification.swift | 13 ++++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/iOSClient/NCGlobal.swift b/iOSClient/NCGlobal.swift index 6198a26f58..75d0d7bf64 100644 --- a/iOSClient/NCGlobal.swift +++ b/iOSClient/NCGlobal.swift @@ -90,6 +90,7 @@ class NCGlobal: NSObject { // let appName = "files" let talkName = "talk-message" + let spreedName = "spreed" let twofactorNotificatioName = "twofactor_nextcloud_notification" let appScheme = "nextcloud" diff --git a/iOSClient/Notification/NCNotification.swift b/iOSClient/Notification/NCNotification.swift index c8667311b6..e856bd27c3 100644 --- a/iOSClient/Notification/NCNotification.swift +++ b/iOSClient/Notification/NCNotification.swift @@ -49,6 +49,13 @@ class NCNotification: UITableViewController, NCNotificationCellDelegate, NCEmpty refreshControl?.addTarget(self, action: #selector(getNetwokingNotification), for: .valueChanged) + // Navigation controller is being presented modally + if navigationController?.presentingViewController != nil { + navigationItem.leftBarButtonItem = UIBarButtonItem(title: NSLocalizedString("_cancel_", comment: ""), style: .plain, action: { [weak self] in + self?.dismiss(animated: true) + }) + } + // Empty let offset = (self.navigationController?.navigationBar.bounds.height ?? 0) - 20 emptyDataSet = NCEmptyDataSet(view: tableView, offset: -offset, delegate: self) @@ -258,7 +265,7 @@ class NCNotification: UITableViewController, NCNotificationCellDelegate, NCEmpty } func tapAction(with notification: NKNotifications, label: String) { - if notification.app == "spreed", + if notification.app == NCGlobal.shared.spreedName, let roomToken = notification.objectId.split(separator: "/").first, let talkUrl = URL(string: "nextcloudtalk://open-conversation?server=\(appDelegate.urlBase)&user=\(appDelegate.userId)&withRoomToken=\(roomToken)"), UIApplication.shared.canOpenURL(talkUrl) { @@ -280,11 +287,15 @@ class NCNotification: UITableViewController, NCNotificationCellDelegate, NCEmpty self.notifications.remove(at: index) } self.tableView.reloadData() + if self.navigationController?.presentingViewController != nil, notification.app == NCGlobal.shared.twofactorNotificatioName { + self.dismiss(animated: true) + } } else if error != .success { NCContentPresenter.shared.showError(error: error) } else { print("[Error] The user has been changed during networking process.") } + } } // else: Action not found } From 8957038d3cb465777d26dbb4e13a37eada236d6c Mon Sep 17 00:00:00 2001 From: Marino Faggiana Date: Mon, 10 Jul 2023 15:43:43 +0200 Subject: [PATCH 7/9] detect twofactor_nextcloud_notification Signed-off-by: Marino Faggiana --- iOSClient/AppDelegate.swift | 13 +++++++++---- .../Supporting Files/en.lproj/Localizable.strings | 2 ++ 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/iOSClient/AppDelegate.swift b/iOSClient/AppDelegate.swift index 0acd2d9d82..0a251fa580 100644 --- a/iOSClient/AppDelegate.swift +++ b/iOSClient/AppDelegate.swift @@ -443,28 +443,33 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD NCApplicationHandle().nextcloudPushNotificationAction(data: data) { detected in if !detected { - var openNotification: Bool = false + var findAccount: Bool = false if let accountPush = data["account"] as? String, let app = data["app"] as? String, app == NCGlobal.shared.twofactorNotificatioName { if accountPush == self.account { - openNotification = true + findAccount = true } else { let accounts = NCManageDatabase.shared.getAllAccount() for account in accounts { if account.account == accountPush { self.changeAccount(account.account) - openNotification = true + findAccount = true } } } - if openNotification, let viewController = UIStoryboard(name: "NCNotification", bundle: nil).instantiateInitialViewController() as? NCNotification { + if findAccount, let viewController = UIStoryboard(name: "NCNotification", bundle: nil).instantiateInitialViewController() as? NCNotification { DispatchQueue.main.asyncAfter(deadline: .now() + 1) { let navigationController = UINavigationController(rootViewController: viewController) navigationController.modalPresentationStyle = .fullScreen self.window?.rootViewController?.present(navigationController, animated: true) } + } else if !findAccount { + let message = NSLocalizedString("_the_account_", comment: "") + " " + accountPush + " " + NSLocalizedString("_does_not_exist_", comment: "") + let alertController = UIAlertController(title: NSLocalizedString("_info_", comment: ""), message: message, preferredStyle: .alert) + alertController.addAction(UIAlertAction(title: NSLocalizedString("_ok_", comment: ""), style: .default, handler: { _ in })) + self.window?.rootViewController?.present(alertController, animated: true, completion: { }) } } } diff --git a/iOSClient/Supporting Files/en.lproj/Localizable.strings b/iOSClient/Supporting Files/en.lproj/Localizable.strings index bb40043984..aeb33ef974 100644 --- a/iOSClient/Supporting Files/en.lproj/Localizable.strings +++ b/iOSClient/Supporting Files/en.lproj/Localizable.strings @@ -113,6 +113,8 @@ "_purchase_" = "Purchase"; "_account_not_available_" = "The account %@ of %@ does not exist, please add it to be able to read the file %@"; "_account_not_exists_" = "The account %@ of %@ does not exist"; +"_the_account_" = "The account"; +"_does_not_exist_" = "does not exist"; "_error_parameter_schema_" = "Wrong parameters, impossible to continue"; "_comments_" = "Comments"; "_sharing_" = "Sharing"; From c8e778d4c9f600763d1d57f533483b0fe042f504 Mon Sep 17 00:00:00 2001 From: Marino Faggiana Date: Mon, 10 Jul 2023 15:48:01 +0200 Subject: [PATCH 8/9] restore standard push notification Signed-off-by: Marino Faggiana --- Brand/NCBrand.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Brand/NCBrand.swift b/Brand/NCBrand.swift index 2d89f5a50f..98471e5db4 100755 --- a/Brand/NCBrand.swift +++ b/Brand/NCBrand.swift @@ -35,7 +35,7 @@ import UIKit @objc public var textCopyrightNextcloudiOS: String = "Nextcloud Liquid for iOS %@ © 2023" @objc public var textCopyrightNextcloudServer: String = "Nextcloud Server %@" @objc public var loginBaseUrl: String = "https://cloud.nextcloud.com" - @objc public var pushNotificationServerProxy: String = "https://c0004.customerpush.nextcloud.com" + @objc public var pushNotificationServerProxy: String = "https://push-notifications.nextcloud.com" @objc public var linkLoginHost: String = "https://nextcloud.com/install" @objc public var linkloginPreferredProviders: String = "https://nextcloud.com/signup-ios" @objc public var webLoginAutenticationProtocol: String = "nc://" // example "abc://" From eddc3bf6ea157690e219ee9d6a3e880e46883163 Mon Sep 17 00:00:00 2001 From: Marino Faggiana Date: Tue, 11 Jul 2023 10:18:02 +0200 Subject: [PATCH 9/9] v 4.8.6 Signed-off-by: Marino Faggiana --- Nextcloud.xcodeproj/project.pbxproj | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Nextcloud.xcodeproj/project.pbxproj b/Nextcloud.xcodeproj/project.pbxproj index bdf7f9c928..6d1a5d1492 100644 --- a/Nextcloud.xcodeproj/project.pbxproj +++ b/Nextcloud.xcodeproj/project.pbxproj @@ -4566,7 +4566,7 @@ CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 1; + CURRENT_PROJECT_VERSION = 0; DEBUG_INFORMATION_FORMAT = dwarf; DEVELOPMENT_TEAM = NKUJUXUJ3B; ENABLE_STRICT_OBJC_MSGSEND = YES; @@ -4592,7 +4592,7 @@ "@executable_path/Frameworks", "@executable_path/../../Frameworks", ); - MARKETING_VERSION = 4.8.5; + MARKETING_VERSION = 4.8.6; ONLY_ACTIVE_ARCH = YES; OTHER_LDFLAGS = ""; SDKROOT = iphoneos; @@ -4631,7 +4631,7 @@ CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 1; + CURRENT_PROJECT_VERSION = 0; DEVELOPMENT_TEAM = NKUJUXUJ3B; ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_TESTABILITY = YES; @@ -4654,7 +4654,7 @@ "@executable_path/Frameworks", "@executable_path/../../Frameworks", ); - MARKETING_VERSION = 4.8.5; + MARKETING_VERSION = 4.8.6; ONLY_ACTIVE_ARCH = YES; OTHER_LDFLAGS = ""; SDKROOT = iphoneos;