iOS camera permissions, album permissions, location rights judgment

Source: Internet
Author: User

1. determine if the user has access to the album

#import <AssetsLibrary/AssetsLibrary.h>

Alauthorizationstatus Author =[Alassetslibraryauthorizationstatus]; if(author = = Kclauthorizationstatusrestricted | | author = =kclauthorizationstatusdenied) {        //No Permissions} typedefenum{kclauthorizationstatusnotdetermined=0,//user has not made a greeting to select this applicationKclauthorizationstatusrestricted,//This application does not have permission to access the photo data. may be Parental control permissionsKclauthorizationstatusdenied,//The user has explicitly denied the application access to this photo dataKclauthorizationstatusauthorized//user has authorized app access to photo data} Clauthorizationstatus;}

2. determine if the user has access to the camera (do not forget to import the Avfoundation library)

IOS7 Before you can access the camera,iOS7 after access to the camera has permission to set

#import <AVFoundation/AVCaptureDevice.h>

#import <AVFoundation/AVMediaFormat.h>

    Avauthorizationstatus authstatus = [Avcapturedevice authorizationstatusformediatype:avmediatypevideo];     if (Authstatus = = Avauthorizationstatusrestricted | | authstatus = =avauthorizationstatusdenied)    {        // no permissions    }

3. determine if the location service is turned on

    // detects whether the location service of the entire iOS system is turned on to detect if the location service for the current app is turned on requires a way to detect    -(void) Locationmanager: (Cllocationmanager *) Manager didfailwitherror: (nserror *) error

iOS camera permissions, album permissions, location rights judgment

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.