Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 22 additions & 6 deletions FirebaseSessions/Sources/SessionInitiator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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),
Expand Down
Loading