Created
October 1, 2022 09:47
-
-
Save arthurschiller/578dd1767acc5c7c66c3072b0c0d7fd5 to your computer and use it in GitHub Desktop.
Utilities to query ARKit GeoTracking support
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// ARSession+GeoTracking.swift | |
// ARExperienceKit | |
// | |
// Created by Arthur Schiller on 22.04.20. | |
// | |
import ARKit | |
import CoreLocation | |
public extension ARSession{ | |
static var supportsLocationAnchors: Bool { | |
return ARGeoTrackingConfiguration.isSupported | |
} | |
@MainActor static func checkLocationAnchorSupport() async throws -> Bool { | |
return try await withCheckedThrowingContinuation { (continuation: CheckedContinuation<Bool, Error>) -> Void in | |
ARGeoTrackingConfiguration.checkAvailability { (isSupported, error) in | |
if let error { | |
continuation.resume(throwing: error) | |
return | |
} | |
continuation.resume(returning: isSupported) | |
} | |
} | |
} | |
@MainActor static func checkLocationAnchorSupport(at coordinate: CLLocationCoordinate2D) async throws -> Bool { | |
return try await withCheckedThrowingContinuation { (continuation: CheckedContinuation<Bool, Error>) -> Void in | |
ARGeoTrackingConfiguration.checkAvailability(at: coordinate, completionHandler: { (isSupported, error) in | |
if let error { | |
continuation.resume(throwing: error) | |
return | |
} | |
continuation.resume(returning: isSupported) | |
}) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment