Forráskód Böngészése

Change iPadOS26 session background listener for session background (#15047)

themiswang 9 hónapja
szülő
commit
b784eb7bda
1 módosított fájl, 22 hozzáadás és 6 törlés
  1. 22 6
      FirebaseSessions/Sources/SessionInitiator.swift

+ 22 - 6
FirebaseSessions/Sources/SessionInitiator.swift

@@ -22,6 +22,12 @@ import Foundation
   import WatchKit
 #endif // os(iOS) || os(tvOS)
 
+#if SWIFT_PACKAGE
+  internal import GoogleUtilities_Environment
+#else
+  internal import GoogleUtilities
+#endif // SWIFT_PACKAGE
+
 /// The SessionInitiator is responsible for:
 ///   1) Running the initiate callback whenever a Session Start Event should
 ///      begin sending. This can happen at a cold start of the app, and when it
@@ -45,12 +51,22 @@ class SessionInitiator {
 
     let notificationCenter = NotificationCenter.default
     #if os(iOS) || os(tvOS) || os(visionOS)
-      notificationCenter.addObserver(
-        self,
-        selector: #selector(appBackgrounded),
-        name: UIApplication.didEnterBackgroundNotification,
-        object: nil
-      )
+      // Change background update event listerner for iPadOS 26 multi-windowing supoort
+      if #available(iOS 26, *), GULAppEnvironmentUtil.appleDevicePlatform().contains("ipados") {
+        notificationCenter.addObserver(
+          self,
+          selector: #selector(appBackgrounded),
+          name: UIApplication.willResignActiveNotification,
+          object: nil
+        )
+      } else {
+        notificationCenter.addObserver(
+          self,
+          selector: #selector(appBackgrounded),
+          name: UIApplication.didEnterBackgroundNotification,
+          object: nil
+        )
+      }
       notificationCenter.addObserver(
         self,
         selector: #selector(appForegrounded),