Skip to content

Commit b784eb7

Browse files
authored
Change iPadOS26 session background listener for session background (#15047)
1 parent eb5786d commit b784eb7

File tree

1 file changed

+22
-6
lines changed

1 file changed

+22
-6
lines changed

FirebaseSessions/Sources/SessionInitiator.swift

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@ import Foundation
2222
import WatchKit
2323
#endif // os(iOS) || os(tvOS)
2424

25+
#if SWIFT_PACKAGE
26+
internal import GoogleUtilities_Environment
27+
#else
28+
internal import GoogleUtilities
29+
#endif // SWIFT_PACKAGE
30+
2531
/// The SessionInitiator is responsible for:
2632
/// 1) Running the initiate callback whenever a Session Start Event should
2733
/// begin sending. This can happen at a cold start of the app, and when it
@@ -45,12 +51,22 @@ class SessionInitiator {
4551

4652
let notificationCenter = NotificationCenter.default
4753
#if os(iOS) || os(tvOS) || os(visionOS)
48-
notificationCenter.addObserver(
49-
self,
50-
selector: #selector(appBackgrounded),
51-
name: UIApplication.didEnterBackgroundNotification,
52-
object: nil
53-
)
54+
// Change background update event listerner for iPadOS 26 multi-windowing supoort
55+
if #available(iOS 26, *), GULAppEnvironmentUtil.appleDevicePlatform().contains("ipados") {
56+
notificationCenter.addObserver(
57+
self,
58+
selector: #selector(appBackgrounded),
59+
name: UIApplication.willResignActiveNotification,
60+
object: nil
61+
)
62+
} else {
63+
notificationCenter.addObserver(
64+
self,
65+
selector: #selector(appBackgrounded),
66+
name: UIApplication.didEnterBackgroundNotification,
67+
object: nil
68+
)
69+
}
5470
notificationCenter.addObserver(
5571
self,
5672
selector: #selector(appForegrounded),

0 commit comments

Comments
 (0)