Giter Club home page Giter Club logo

arcamerapermissiontemplate's Introduction

AR Camera Permission Templete

This project is a template to deal with camera permission with ARKit. According to Apple Human Interface Guidelines we have to explain by description in an alert dialog the reason why the application needs permissions. However Apple rejected my application because it did not have a function which requests permission again when it appeared. This function is common at most of applications, so I decided make a template which requests a camera permission.

source codes refer to Swift Cheat Sheet for iPhone Camera Access & Usage.

How it Works

  • let cameraAuthorizationStatus = AVCaptureDevice.authorizationStatus(for: .video) is getting present authenticate status. We can handle it at ViewDidAppear().

  • checkPermission() is checking present status and executing operations by each states

    • .notDetermined
      request a permission by calling requestCameraPermission() It shows alert dialog generated by iOS. We have to describe explanation on it, and it is declared at InfoPlist.strings.

    • .restricted & .denied ask to set a permission by alertCameraAccessNeeded() It shows application original alert dialog.

    • .authorized
      Do nothing. (We have to implement operations after getting a permission)

  • NotificationCenter.default.addObserver(self, selector: #selector(checkPermission), name: UIApplication.willEnterForegroundNotification, object: nil) is for showing a dialog automatically when the application comes back foreground.

To Run

  1. Prerquisites: You must have a device running iOS 9 and more higher with an A9 or later processor and XCode 10.1. Both of these are currently in beta but are available via the Apple Developer portal.
  2. Download the source code for this project and open the project in XCode 10.1.
  3. Change the Bundle Identifier and Team to your own unique identifier and team. Note that this project does not require a developer license to run on a phone, so you can use a personal team.
  4. Run in XCode on your device.

arcamerapermissiontemplate's People

Contributors

nob3rise avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.