Skip to content

Commit

Permalink
https://github.com/nextcloud/ios/issues/2291
Browse files Browse the repository at this point in the history
Signed-off-by: Marino Faggiana <[email protected]>
  • Loading branch information
marinofaggiana committed May 20, 2024
1 parent ec0b41b commit 2482a14
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions iOSClient/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
var isUiTestingEnabled: Bool {
return ProcessInfo.processInfo.arguments.contains("UI_TESTING")
}
var notificationSettings: UNNotificationSettings?

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
if isUiTestingEnabled {
Expand Down Expand Up @@ -126,6 +127,9 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
NCImageCache.shared.createImagesCache()

// Push Notification & display notification
UNUserNotificationCenter.current().getNotificationSettings { settings in
self.notificationSettings = settings
}
application.registerForRemoteNotifications()
UNUserNotificationCenter.current().delegate = self
UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .badge, .sound]) { _, _ in }
Expand All @@ -149,9 +153,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD

// L'applicazione terminerà
func applicationWillTerminate(_ application: UIApplication) {

if UIApplication.shared.backgroundRefreshStatus == .available {

if self.notificationSettings?.authorizationStatus != .denied && UIApplication.shared.backgroundRefreshStatus == .available {
let content = UNMutableNotificationContent()
content.title = NCBrandOptions.shared.brand
content.body = NSLocalizedString("_keep_running_", comment: "")
Expand Down

0 comments on commit 2482a14

Please sign in to comment.