Customized push notification permission requests
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
Example
Pod
Screenshots
.gitignore
.travis.yml
APNPermissionRequest.podspec
LICENSE
README.md

README.md

APNPermissionRequest

CI Status Version License Platform

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

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

pod "APNPermissionRequest"

Author

Tilo Westermann, tilo.westermann@tu-berlin.de

References

APNPermissionRequest is inspired by ClusterPrePermissions.

License

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