CocoaPods trunk is moving to be read-only. Read more on the blog, there are 8 months to go.

APNPermissionRequest 0.1.5

APNPermissionRequest 0.1.5

TestsTested
LangLanguage Obj-CObjective C
License MIT
ReleasedLast Release Sep 2015

Maintained by Tilo Westermann.



APNPermissionRequest allows your users to make informed choices on whether to allow or disallow push notifications. The default push notification permission request doesn't give a hint on the nature of notifications and users might deny the request just because they feel unsure. With APNPermissionRequest you may add a) an additional explanatory string to the request and also b) notification settings, so that the user may decide which modality to receive, without navigating to the system Settings app.

Usage

To run the example project, clone the repo, and run pod install from the Example directory first.

Permission request with explanation

Permission request with explanation

APNPermissionRequest *request = [APNPermissionRequest sharedRequest];
[request showWithType: APNTypeAlert | APNTypeSound
                title:@"\"MyMailman\" Would Like to Send You Notifications."
              message:@"Your delivery is ready for pick-up at the post office? We'll inform you immediately via a push notification!"
      denyButtonTitle:@"Don't allow"
     grantButtonTitle:@"OK"
    completionHandler:^(BOOL hasPermission,
                        APNPermissionRequestDialogResult userDialogResult,
                        APNPermissionRequestDialogResult systemDialogResult) {
        NSLog(@"Permission: %d",hasPermission);

        NSArray *actions = @[@"no action",@"denied", @"granted"];
        NSLog(@"user action: %@",actions[userDialogResult]);
        NSLog(@"system action: %@",actions[systemDialogResult]);
        NSLog(@"Settings: %@",[APNPermissionRequest enabledTypeNames]);
    }];

Permission request with options

Permission request with notification settings

APNPermissionRequest *request = [APNPermissionRequest sharedRequest];
[request showWithType: APNTypeAlert | APNTypeSound
                  title:@"\"MyMailman\" Would Like to Send You Notifications."
                message:@"Your delivery is ready for pick-up at the post office? We'll inform you immediately via a push notification!"
         optionsTitle:@"Notification settings"
      denyButtonTitle:@"Don't allow"
     grantButtonTitle:@"OK"
    completionHandler:^(BOOL hasPermission,
                        APNPermissionRequestDialogResult userDialogResult,
                        APNPermissionRequestDialogResult systemDialogResult) {
        NSLog(@"Permission: %d",hasPermission);

        NSArray *actions = @[@"no action",@"denied", @"granted"];
        NSLog(@"user action: %@",actions[userDialogResult]);
        NSLog(@"system action: %@",actions[systemDialogResult]);
        NSLog(@"Settings: %@",[APNPermissionRequest enabledTypeNames]);
    }];

Fullscreen permission request

Fullscreen permission request

APNPermissionRequest *request = [APNPermissionRequest sharedRequest];
request.backgroundColor = [UIColor colorWithRed:236.0/255.0 green:240.0/255.0 blue:241.0/255.0 alpha:1];

NSMutableAttributedString *message = [[NSMutableAttributedString alloc] initWithString:@"Your delivery is ready for pick-up at the post office? We'll inform you immediately via a push notification!"];
[message addAttribute:NSFontAttributeName
                value:[UIFont italicSystemFontOfSize:14]
                range:[message rangeOfString:@"push notification"]];
[request showFullscreenWithType: APNTypeAlert | APNTypeSound
                          title:@"\"MyMailman\" Would Like to Send You Notifications."
                        message:message
                   optionsTitle:@"Notification settings"
                denyButtonTitle:@"Don't allow"
               grantButtonTitle:@"OK"
              completionHandler:^(BOOL hasPermission,
                        APNPermissionRequestDialogResult userDialogResult,
                        APNPermissionRequestDialogResult systemDialogResult) {
                                NSLog(@"Permission: %d",hasPermission);

                                NSArray *actions = @[@"no action",@"denied", @"granted"];
                                NSLog(@"user action: %@",actions[userDialogResult]);
                                NSLog(@"system action: %@",actions[systemDialogResult]);
                                NSLog(@"Settings: %@",[APNPermissionRequest enabledTypeNames]);
}];

Requirements

SDCAlertView

Installation

Author

Tilo Westermann, [email protected]

References

APNPermissionRequest is inspired by ClusterPrePermissions.

License

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