apnpermissionrequest

About APNPermissionRequest

APNPermissionRequest is a lightweight library for requesting user’s permission to show push notifications in iOS apps. It simplifies the process of handling push notification permission requests and provides a seamless user experience.

Features

  • Simple and easy-to-use push notification permission request handling.
  • Clear and customizable permission request prompts.
  • Handles all permission states, including authorized, denied, and not determined.
  • Works with both local and remote push notifications.

Installation

To install APNPermissionRequest in your iOS app, follow these steps:

  • Add the following line to your Podfile:
pod 'APNPermissionRequest'

Run the following command in your project directory:

pod install

Usage

Here’s an example of how to use APNPermissionRequest in your app:

// Import the library
import APNPermissionRequest

// Create an instance of APNPermissionRequest
let permissionRequest = APNPermissionRequest()

// Request permission
permissionRequest.request { permissionGranted in
    if permissionGranted {
        // Permission granted, handle push notifications
        // Add your notification handling code here
    } else {
        // Permission denied or not determined, handle accordingly
        // Add code to handle denied permission or show custom prompt
    }
}

Make sure you have added the necessary entries in your app’s Info.plist file to handle push notifications. Please refer to the Apple documentation for more details on setting up push notifications in your app.

Customization

APNPermissionRequest allows you to customize the permission request prompt. You can change the title, message, and button titles to match your app’s branding or localization requirements. Here’s how:

// Customize the permission request prompt
let permissionRequest = APNPermissionRequest()
permissionRequest.title = "Custom Title"
permissionRequest.message = "Custom Message"
permissionRequest.cancelButtonTitle = "Cancel"
permissionRequest.grantButtonTitle = "Allow"

// Request permission
permissionRequest.request { permissionGranted in
    // Handle permission request result
}

By setting these properties before calling the request method, you can provide a customized permission request prompt to the user.

Requirements

APNPermissionRequest requires iOS 10.0 or later and Swift 4.2 or later. It is compatible with both iPhone and iPad devices.

Contributing

If you would like to contribute to APNPermissionRequest, please follow these steps:

1. Fork the repository and clone it locally.

2. Create a new branch for your changes.

3. Make your changes and test them.

4. Commit your changes and push them to your fork.

5. Submit a pull request, explaining the changes you have made and the reason for them.

License

APNPermissionRequest is released under the MIT License. See the LICENSE file for more information.