Skip to content

Commit

Permalink
fix: add visionOS Support
Browse files Browse the repository at this point in the history
  • Loading branch information
sojingle committed Nov 14, 2024
1 parent 700637b commit 6cbe7ab
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 6 additions & 2 deletions Sources/Amplitude/Plugins/Vendors/AppUtil.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import Foundation

#if (os(iOS) || os(tvOS) || targetEnvironment(macCatalyst)) && !AMPLITUDE_DISABLE_UIKIT
#if (os(iOS) || os(tvOS) || os(visionOS) || targetEnvironment(macCatalyst)) && !AMPLITUDE_DISABLE_UIKIT
import SystemConfiguration
import UIKit

Expand Down Expand Up @@ -35,6 +35,8 @@ import Foundation
override var platform: String {
#if os(tvOS)
return "tvOS"
#elseif os(visionOS)
return "visionOS"
#elseif targetEnvironment(macCatalyst)
return "macOS"
#else
Expand All @@ -56,10 +58,12 @@ import Foundation
let platform = getPlatformString()
return getDeviceModel(platform: platform)
}


#if !os(visionOS)
override var requiredPlugin: Plugin {
return IOSLifecycleMonitor()
}
#endif

override func beginBackgroundTask() -> BackgroundTaskCompletionCallback? {
if !isRunningInAppExtension, let application = IOSVendorSystem.sharedApplication {
Expand Down
2 changes: 1 addition & 1 deletion Sources/Amplitude/Plugins/Vendors/VendorSystem.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ internal class VendorSystem {
}

static var current: VendorSystem = {
#if (os(iOS) || os(tvOS) || targetEnvironment(macCatalyst)) && !AMPLITUDE_DISABLE_UIKIT
#if (os(iOS) || os(tvOS) || os(visionOS) || targetEnvironment(macCatalyst)) && !AMPLITUDE_DISABLE_UIKIT
return IOSVendorSystem()
#elseif os(macOS)
return MacOSVendorSystem()
Expand Down

0 comments on commit 6cbe7ab

Please sign in to comment.