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
36 changes: 2 additions & 34 deletions FirebaseSessions/Sources/SessionInitiator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
// limitations under the License.

import Foundation
#if os(iOS) || os(tvOS)
#if os(iOS) || os(tvOS) || os(visionOS)
import UIKit
#elseif os(macOS)
import AppKit
Expand All @@ -22,17 +22,6 @@ import Foundation
import WatchKit
#endif // os(iOS) || os(tvOS)

// swift(>=5.9) implies Xcode 15+
// Need to have this Swift version check to use os(visionOS) macro, VisionOS support.
// TODO: Remove this check and add `os(visionOS)` to the `os(iOS) || os(tvOS)` conditional above
// when Xcode 15 is the minimum supported by Firebase.
#if swift(>=5.9)
#if os(visionOS)
import UIKit
#endif // os(visionOS)
#endif // swift(>=5.9)

///
/// 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 @@ -55,7 +44,7 @@ class SessionInitiator {
self.initiateSessionStart()

let notificationCenter = NotificationCenter.default
#if os(iOS) || os(tvOS)
#if os(iOS) || os(tvOS) || os(visionOS)
notificationCenter.addObserver(
self,
selector: #selector(appBackgrounded),
Expand Down Expand Up @@ -98,27 +87,6 @@ class SessionInitiator {
)
}
#endif // os(iOS) || os(tvOS)

// swift(>=5.9) implies Xcode 15+
// Need to have this Swift version check to use os(visionOS) macro, VisionOS support.
// TODO: Remove this check and add `os(visionOS)` to the `os(iOS) || os(tvOS)` conditional above
// when Xcode 15 is the minimum supported by Firebase.
#if swift(>=5.9)
#if os(visionOS)
notificationCenter.addObserver(
self,
selector: #selector(appBackgrounded),
name: UIApplication.didEnterBackgroundNotification,
object: nil
)
notificationCenter.addObserver(
self,
selector: #selector(appForegrounded),
name: UIApplication.didBecomeActiveNotification,
object: nil
)
#endif // os(visionOS)
#endif // swift(>=5.9)
}

@objc private func appBackgrounded() {
Expand Down
Loading