又是一個很多年前的輪子. 在很多項目中都有用過, 所以整理出來發佈了一個開源 pod. XD
PRPrivacyManager
All-in-one privacy manager for iOS.
Currently supported:
Installation
With CocoaPods
In your Podfile:
pod 'PRPrivacyManager'
Usage
Check for Status
PRPrivacyStatus privacyStatus = [PRPrivacyManager privacyStatusForType:PRPrivacyTypeContacts];
Ask for Permission
[PRPrivacyManager authorizeWithType:PRPrivacyTypeContacts
completion:^(TTPrivacyStatus status) {
// Handle result
}];
Available Types
typedef NS_ENUM(NSUInteger, PRPrivacyType) {
PRPrivacyTypeContacts,
PRPrivacyTypePhotos,
PRPrivacyTypeMicrophone,
PRPrivacyTypeCamera
};
Statuses
typedef NS_ENUM(NSUInteger, PRPrivacyStatus) {
PRPrivacyStatusNotDetermined,
PRPrivacyStatusRestricted,
PRPrivacyStatusDenied,
PRPrivacyStatusAuthorized
};
All done! You can check out the code in the demo provided.
License
This code is distributed under the terms and conditions of the MIT license.
Donate
You can support me by:
- sending me iTunes Gift Cards;
- via Alipay: [email protected]
- via PayPal: [email protected]
:-)
