Latest 0.1.4
Homepage https://github.com/ablettchen/ATPermission
License MIT
Platforms ios 8.0, requires ARC
Dependencies ATCategories
Authors

CI Status
Version
License
Platform

Introduce

ATPermission 为 PermissionScope 的 Objective-C 版本,感谢 nickoneill 大神无私奉献!

支持权限:

  • Notifications
  • Location (WhileInUse, Always)
  • Contacts
  • Events
  • Microphone
  • Camera
  • Photos
  • Reminders
  • Bluetooth
  • Motion

支持英文与简体中文

Example

#import "ATPermission.h"

self.singlePermission   = [ATPermission new];
    self.multiPermission    = [ATPermission new];
    self.noUIPermission     = [ATPermission new];

    [self.singlePermission addPermission:[[ATNotificationsPermission alloc] initWithNotificationCategories:nil]
                                 message:@"We use this to send yournspam and love notes"];

    [self.multiPermission addPermission:[[ATContactsPermission alloc] init]
                                message:@"We use this to stealrnyour friends"];
    [self.multiPermission addPermission:[[ATNotificationsPermission alloc] initWithNotificationCategories:nil]
                                message:@"We use this to send yournspam and love notes"];
    [self.multiPermission addPermission:[[ATLocationWhileInUsePermission alloc] init]
                                message:@"We use this to trackrnwhere you live"];

    [self.noUIPermission addPermission:[[ATNotificationsPermission alloc] initWithNotificationCategories:nil] message:@"notifications"];
    [self.noUIPermission addPermission:[ATMicrophonePermission new] message:@"microphone"];

    - (void)singlePermissionAction:(UIButton *)sender {
    [self.singlePermission show:^(BOOL finished, NSArray<ATPermissionResult *> * _Nonnull results) {
        NSLog(@"Changed: %@ - %@", @(finished), results);
    } cancelled:^(NSArray<ATPermissionResult *> * _Nonnull results) {
        NSLog(@"Cancelled");
    }];
}

- (void)multiPermissionAction:(UIButton *)sender {
    [self.multiPermission show:^(BOOL finished, NSArray<ATPermissionResult *> * _Nonnull results) {
        NSLog(@"Changed: %@ - %@", @(finished), results);
    } cancelled:^(NSArray<ATPermissionResult *> * _Nonnull results) {
        NSLog(@"Cancelled");
    }];
}

- (void)noUIPermissionAction:(UIButton *)sender {
    [self.noUIPermission requestNotifications];
}

- (void)statusContactsPermissionAction:(UIButton *)sender {
    ATPermission *p = [ATPermission new];
    //p.viewControllerForAlerts = self;
    ATPermissionStatus status = [p statusContacts];
    if (status != kATPermissionStatusAuthorized) {
        [p requestContacts];
    }
    ATPermissionResult *result = ATPermissionResultMake(kATPermissionTypeContacts, status);
    [sender setTitle:result.description forState:UIControlStateNormal];
}

Requirements

Installation

ATPermission is available through CocoaPods. To install
it, simply add the following line to your Podfile:

pod 'ATPermission'

Author

[email protected], [email protected]

License

ATPermission is available under the MIT license. See the LICENSE file for more info.

Latest podspec

{
    "name": "ATPermission",
    "version": "0.1.4",
    "summary": "u7cfbu7edfu6743u9650u8bf7u6c42",
    "homepage": "https://github.com/ablettchen/ATPermission",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "ablett": "[email protected]"
    },
    "source": {
        "git": "https://github.com/ablettchen/ATPermission.git",
        "tag": "0.1.4"
    },
    "social_media_url": "https://twitter.com/ablettchen",
    "platforms": {
        "ios": "8.0"
    },
    "source_files": "ATPermission/**/*.{h,m}",
    "resources": "ATPermission/ATPermission.bundle",
    "requires_arc": true,
    "dependencies": {
        "ATCategories": []
    }
}

Pin It on Pinterest

Share This