Parcourir la source

show unconditional notification-banner on notification-hooks

B. Petersen il y a 4 ans
Parent
commit
c97faad7c9
2 fichiers modifiés avec 16 ajouts et 2 suppressions
  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
                 content.sound = .default
 
 
                 let trigger = UNTimeIntervalNotificationTrigger(timeInterval: 0.1, repeats: false)
                 let trigger = UNTimeIntervalNotificationTrigger(timeInterval: 0.1, repeats: false)
-
                 let request = UNNotificationRequest(identifier: Constants.notificationIdentifier, content: content, trigger: trigger)
                 let request = UNNotificationRequest(identifier: Constants.notificationIdentifier, content: content, trigger: trigger)
                 UNUserNotificationCenter.current().add(request, withCompletionHandler: nil)
                 UNUserNotificationCenter.current().add(request, withCompletionHandler: nil)
                 DcContext.shared.logger?.info("notifications: added \(content)")
                 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))"
         msg.text = "I. remoteNotification: \(String(describing: notificationOption))"
         dcContext.addDeviceMessage(label: nil, msg: msg)
         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") {
         if dcContext.isConfigured() && !UserDefaults.standard.bool(forKey: "notifications_disabled") {
             registerForNotifications()
             registerForNotifications()
         }
         }
@@ -351,7 +359,14 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
         let msg = DcMsg(viewType: DC_MSG_TEXT)
         let msg = DcMsg(viewType: DC_MSG_TEXT)
         msg.text = "II. didReceiveRemoteNotification: \(String(describing: userInfo))"
         msg.text = "II. didReceiveRemoteNotification: \(String(describing: userInfo))"
         dcContext.addDeviceMessage(label: nil, msg: msg)
         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) {
     private func userNotificationCenter(_: UNUserNotificationCenter, willPresent _: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {