From 076b844f7e554f9c7a9c6b7d2f6bf6390c059d73 Mon Sep 17 00:00:00 2001 From: Daniel Li Date: Thu, 22 Feb 2018 00:47:56 -0500 Subject: [PATCH] Disable arkit button for non-compatible devices --- Eatery Watch App Extension/Info.plist | 2 +- Eatery Watch App/Info.plist | 2 +- Eatery/Controllers/ARViewController.swift | 5 +++++ Eatery/Controllers/EateriesViewController.swift | 7 +++++-- Eatery/Info.plist | 2 +- 5 files changed, 13 insertions(+), 5 deletions(-) diff --git a/Eatery Watch App Extension/Info.plist b/Eatery Watch App Extension/Info.plist index 347559c1..1167f574 100644 --- a/Eatery Watch App Extension/Info.plist +++ b/Eatery Watch App Extension/Info.plist @@ -21,7 +21,7 @@ CFBundleSignature ???? CFBundleVersion - 1 + 2 NSExtension NSExtensionAttributes diff --git a/Eatery Watch App/Info.plist b/Eatery Watch App/Info.plist index 416150bb..36ae9f1e 100644 --- a/Eatery Watch App/Info.plist +++ b/Eatery Watch App/Info.plist @@ -21,7 +21,7 @@ CFBundleSignature ???? CFBundleVersion - 1 + 2 UISupportedInterfaceOrientations UIInterfaceOrientationPortrait diff --git a/Eatery/Controllers/ARViewController.swift b/Eatery/Controllers/ARViewController.swift index a30f0c9a..88d0ac30 100644 --- a/Eatery/Controllers/ARViewController.swift +++ b/Eatery/Controllers/ARViewController.swift @@ -1,5 +1,6 @@ import UIKit import ARCL +import ARKit import SceneKit import CoreLocation import DiningStack @@ -21,6 +22,10 @@ class ARViewController: UIViewController, CLLocationManagerDelegate, SceneLocati case none } + static func isSupported() -> Bool { + return ARWorldTrackingConfiguration.isSupported + } + override func viewDidLoad() { super.viewDidLoad() diff --git a/Eatery/Controllers/EateriesViewController.swift b/Eatery/Controllers/EateriesViewController.swift index fd0faadc..eca8113a 100644 --- a/Eatery/Controllers/EateriesViewController.swift +++ b/Eatery/Controllers/EateriesViewController.swift @@ -71,6 +71,7 @@ class EateriesViewController: UIViewController, MenuButtonsDelegate, CLLocationM let mapButton = UIBarButtonItem(image: #imageLiteral(resourceName: "mapIcon"), style: .done, target: self, action: #selector(mapButtonPressed)) mapButton.imageInsets = UIEdgeInsets(top: 0.0, left: 8.0, bottom: 4.0, right: 8.0) + navigationItem.rightBarButtonItems = [mapButton] if #available(iOS 11.0, *) { navigationController?.navigationBar.prefersLargeTitles = true @@ -86,8 +87,10 @@ class EateriesViewController: UIViewController, MenuButtonsDelegate, CLLocationM self.appDevLogo = logo - let arButton = UIBarButtonItem(title: "AR", style: .done, target: self, action: #selector(arButtonPressed)) - navigationItem.rightBarButtonItems = [mapButton, UIBarButtonItem(barButtonSystemItem: .fixedSpace, target: nil, action: nil), arButton] + if ARViewController.isSupported() { + let arButton = UIBarButtonItem(title: "AR", style: .done, target: self, action: #selector(arButtonPressed)) + navigationItem.rightBarButtonItems?.append(contentsOf: [UIBarButtonItem(barButtonSystemItem: .fixedSpace, target: nil, action: nil), arButton]) + } } else { navigationItem.rightBarButtonItems = [mapButton] } diff --git a/Eatery/Info.plist b/Eatery/Info.plist index 752e4f6a..576ad139 100644 --- a/Eatery/Info.plist +++ b/Eatery/Info.plist @@ -29,7 +29,7 @@ CFBundleVersion - 1 + 2 Fabric APIKey