Browse Source

show unconditional notification-banner on notification-hooks

B. Petersen 4 years ago
parent
commit
c97faad7c9
2 changed files with 16 additions and 2 deletions
  1. 0 1
      DcCore/DcCore/DC/events.swift
  2. 16 1
      deltachat-ios/AppDelegate.swift

+ 0 - 1
DcCore/DcCore/DC/events.swift

@@ -155,7 +155,6 @@ public func handleEvent(event: DcEvent) {
                 content.sound = .default
 
                 let trigger = UNTimeIntervalNotificationTrigger(timeInterval: 0.1, repeats: false)
-
                 let request = UNNotificationRequest(identifier: Constants.notificationIdentifier, content: content, trigger: trigger)
                 UNUserNotificationCenter.current().add(request, withCompletionHandler: nil)
                 DcContext.shared.logger?.info("notifications: added \(content)")

+ 16 - 1
deltachat-ios/AppDelegate.swift

@@ -73,6 +73,14 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
         msg.text = "I. remoteNotification: \(String(describing: notificationOption))"
         dcContext.addDeviceMessage(label: nil, msg: msg)
 
+        let content = UNMutableNotificationContent()
+        content.title = "I. TITLE"
+        content.body = "I. BODY"
+        content.sound = .default
+        let trigger = UNTimeIntervalNotificationTrigger(timeInterval: 0.1, repeats: false)
+        let request = UNNotificationRequest(identifier: Constants.notificationIdentifier, content: content, trigger: trigger)
+        UNUserNotificationCenter.current().add(request, withCompletionHandler: nil)
+
         if dcContext.isConfigured() && !UserDefaults.standard.bool(forKey: "notifications_disabled") {
             registerForNotifications()
         }
@@ -351,7 +359,14 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
         let msg = DcMsg(viewType: DC_MSG_TEXT)
         msg.text = "II. didReceiveRemoteNotification: \(String(describing: userInfo))"
         dcContext.addDeviceMessage(label: nil, msg: msg)
-        
+
+        let content = UNMutableNotificationContent()
+        content.title = "II. TITLE"
+        content.body = "II. BODY"
+        content.sound = .default
+        let trigger = UNTimeIntervalNotificationTrigger(timeInterval: 0.1, repeats: false)
+        let request = UNNotificationRequest(identifier: Constants.notificationIdentifier, content: content, trigger: trigger)
+        UNUserNotificationCenter.current().add(request, withCompletionHandler: nil)
     }
     
     private func userNotificationCenter(_: UNUserNotificationCenter, willPresent _: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {