Browse Source

show device msg for didReceiveRemoteNotification

B. Petersen 4 years ago
parent
commit
e3899f30e0
1 changed files with 11 additions and 5 deletions
  1. 11 5
      deltachat-ios/AppDelegate.swift

+ 11 - 5
deltachat-ios/AppDelegate.swift

@@ -70,13 +70,14 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
         logger.info("Notifications: remoteNotification: \(String(describing: notificationOption))")
         logger.info("Notifications: remoteNotification: \(String(describing: notificationOption))")
 
 
         let msg = DcMsg(viewType: DC_MSG_TEXT)
         let msg = DcMsg(viewType: DC_MSG_TEXT)
-        msg.text = "remoteNotification: \(String(describing: notificationOption))"
+        msg.text = "I. remoteNotification: \(String(describing: notificationOption))"
         dcContext.addDeviceMessage(label: nil, msg: msg)
         dcContext.addDeviceMessage(label: nil, msg: msg)
 
 
         if dcContext.isConfigured() && !UserDefaults.standard.bool(forKey: "notifications_disabled") {
         if dcContext.isConfigured() && !UserDefaults.standard.bool(forKey: "notifications_disabled") {
             registerForNotifications()
             registerForNotifications()
         }
         }
 
 
+
         return true
         return true
     }
     }
 
 
@@ -336,16 +337,21 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
     }
     }
 
 
     func application(
     func application(
-      _ application: UIApplication,
-      didFailToRegisterForRemoteNotificationsWithError error: Error) {
-      print("Notifications: Failed to register: \(error)")
+        _ application: UIApplication,
+        didFailToRegisterForRemoteNotificationsWithError error: Error) {
+        print("Notifications: Failed to register: \(error)")
     }
     }
     
     
-     func application(
+    func application(
         _ application: UIApplication,
         _ application: UIApplication,
         didReceiveRemoteNotification userInfo: [AnyHashable: Any]) {
         didReceiveRemoteNotification userInfo: [AnyHashable: Any]) {
         // TODO: got notification from apple, check for new messages
         // TODO: got notification from apple, check for new messages
         print("Notifications: didReceiveRemoteNotification", userInfo)
         print("Notifications: didReceiveRemoteNotification", userInfo)
+
+        let msg = DcMsg(viewType: DC_MSG_TEXT)
+        msg.text = "II. didReceiveRemoteNotification: \(String(describing: userInfo))"
+        dcContext.addDeviceMessage(label: nil, msg: msg)
+        
     }
     }
     
     
     private func userNotificationCenter(_: UNUserNotificationCenter, willPresent _: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
     private func userNotificationCenter(_: UNUserNotificationCenter, willPresent _: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {