Skip to content

Commit

Permalink
Fix #173
Browse files Browse the repository at this point in the history
  • Loading branch information
robomex committed Jul 19, 2019
1 parent d7687f1 commit 17ae2ce
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
4 changes: 0 additions & 4 deletions XRViewer/Utilities/Constants.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@

import Foundation

/// The NSUserDefaults key for the boolean that tells us whether
/// the permissions UI was already shown
let PermissionsUIAlreadyShownKey = "permissionsUIAlreadyShown"
/// The NSUserDefaults key for the boolean that tells us whether
/// the AnalyticsManager should be used
let UseAnalyticsKey = "useAnalytics"
Expand Down Expand Up @@ -73,7 +70,6 @@ let BOX_SIZE: CGFloat = 0.05
@objc class Constant: NSObject {
override private init() {}

@objc static func permissionsUIAlreadyShownKey() -> String { return PermissionsUIAlreadyShownKey}
static func useAnalyticsKey() -> String { return UseAnalyticsKey }
@objc static func homeURLKey() -> String { return HomeURLKey }
@objc static func secondsInBackgroundKey() -> String { return SecondsInBackgroundKey }
Expand Down
17 changes: 9 additions & 8 deletions XRViewer/ViewController/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,6 @@ class ViewController: UIViewController, UIGestureRecognizerDelegate, GCDWebServe
swipeGestureRecognizer.direction = .up
swipeGestureRecognizer.delegate = self
view.addGestureRecognizer(swipeGestureRecognizer)

/// Show the permissions popup if we have never shown it
if UserDefaults.standard.bool(forKey: Constant.permissionsUIAlreadyShownKey()) == false && (CLLocationManager.authorizationStatus() == .notDetermined || AVCaptureDevice.authorizationStatus(for: .video) == .notDetermined) {
DispatchQueue.main.async(execute: {
UserDefaults.standard.set(true, forKey: Constant.permissionsUIAlreadyShownKey())
self.messageController?.showPermissionsPopup()
})
}

setupTargetControllers()
}
Expand Down Expand Up @@ -113,6 +105,15 @@ class ViewController: UIViewController, UIGestureRecognizerDelegate, GCDWebServe
}
#endif

override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)

// Show the permissions popup if either permissions are .notDetermined
if CLLocationManager.authorizationStatus() == .notDetermined || AVCaptureDevice.authorizationStatus(for: .video) == .notDetermined {
messageController?.showPermissionsPopup()
}
}

override func viewDidDisappear(_ animated: Bool) {
super.viewDidDisappear(animated)

Expand Down

0 comments on commit 17ae2ce

Please sign in to comment.