Skip to content

Instantly share code, notes, and snippets.

@arthurschiller
Created October 1, 2022 09:47
Show Gist options
  • Save arthurschiller/578dd1767acc5c7c66c3072b0c0d7fd5 to your computer and use it in GitHub Desktop.
Save arthurschiller/578dd1767acc5c7c66c3072b0c0d7fd5 to your computer and use it in GitHub Desktop.
Utilities to query ARKit GeoTracking support
//
// 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