Skip to content

Commit

Permalink
add support for visionOS
Browse files Browse the repository at this point in the history
  • Loading branch information
goenning committed Feb 8, 2024
1 parent 157685d commit 873758d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
4 changes: 2 additions & 2 deletions Sources/Aptabase/Aptabase.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Foundation

#if os(iOS)
#if os(iOS) || os(visionOS)
import UIKit
#elseif os(macOS)
import AppKit
Expand Down Expand Up @@ -36,7 +36,7 @@ public class Aptabase: NSObject {
client = AptabaseClient(appKey: appKey, baseUrl: baseUrl, env: env, options: options)

let notifications = NotificationCenter.default
#if os(tvOS) || os(iOS)
#if os(tvOS) || os(iOS) || os(visionOS)
notifications.addObserver(self, selector: #selector(startPolling), name: UIApplication.willEnterForegroundNotification, object: nil)
notifications.addObserver(self, selector: #selector(stopPolling), name: UIApplication.didEnterBackgroundNotification, object: nil)
#elseif os(macOS)
Expand Down
10 changes: 6 additions & 4 deletions Sources/Aptabase/EnvironmentInfo.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#if os(iOS)
import Foundation

#if os(iOS) || os(visionOS)
import UIKit
#elseif os(macOS)
import AppKit
Expand Down Expand Up @@ -50,6 +52,8 @@ struct EnvironmentInfo {
"watchOS"
#elseif os(tvOS)
"tvOS"
#elseif os(visionOS)
"visionOS"
#else
""
#endif
Expand All @@ -59,12 +63,10 @@ struct EnvironmentInfo {
#if os(macOS) || targetEnvironment(macCatalyst)
let os = ProcessInfo.processInfo.operatingSystemVersion
return "\(os.majorVersion).\(os.minorVersion).\(os.patchVersion)"
#elseif os(iOS)
#elseif os(iOS) || os(tvOS) || os(visionOS)
UIDevice.current.systemVersion
#elseif os(watchOS)
WKInterfaceDevice.current().systemVersion
#elseif os(tvOS)
UIDevice.current.systemVersion
#else
""
#endif
Expand Down

0 comments on commit 873758d

Please sign in to comment.