PHPackages                             rajchotaliya/apple-push-notification-service - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Mail &amp; Notifications](/categories/mail)
4. /
5. rajchotaliya/apple-push-notification-service

ActiveLibrary[Mail &amp; Notifications](/categories/mail)

rajchotaliya/apple-push-notification-service
============================================

A PHP package to send push notifications using Apple's APNs.

1.4.0(1y ago)518MITPHPPHP &gt;=8.0

Since Feb 1Pushed 1y ago1 watchersCompare

[ Source](https://github.com/RajChotaliya/apple-push-notification-service)[ Packagist](https://packagist.org/packages/rajchotaliya/apple-push-notification-service)[ RSS](/packages/rajchotaliya-apple-push-notification-service/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (3)Used By (0)

Apple Push Notification Service (APNs)
======================================

[](#apple-push-notification-service-apns)

A PHP library to send push notifications to Apple devices using the APNs service.

Installation
------------

[](#installation)

Install the library using Composer:

```
composer require rajchotaliya/apple-push-notification-service
```

---

Usage
-----

[](#usage)

### Laravel

[](#laravel)

1. **Configuration :**

    - **Environment Variables (Required)**

        Add the following entries to your `.env` file:

        ```
        APNS_BUNDLE_ID=your_bundle_id
        APNS_KEY_ID=your_key_id
        APNS_TEAM_ID=your_team_id
        APNS_PRIVATE_KEY_PATH=/path/to/your/AuthKey.p8
        ```
    - **Publish Config File (Optional)**

        After installing the package, publish the configuration file using the following Artisan command:

        ```
        php artisan vendor:publish --provider="RajChotaliya\ApplePushNotificationService\ApplePushNotificationServiceProvider"
        ```

        This will publish the `apns.php` file into your Laravel project's `config` directory. You can then customize it to fit your needs.

        Example configuration in `config/apns.php`:

        ```
        return  [
           'bundle_id' => env('APNS_BUNDLE_ID', ''),
           'key_id' => env('APNS_KEY_ID', ''),
           'team_id' => env('APNS_TEAM_ID', ''),
           'private_key_path' => env('APNS_PRIVATE_KEY_PATH', storage_path('AuthKey.p8')),
        ];
        ```
2. **Using the Library:**

    You can use the library in your Laravel application as follows:

    ```
    use RajChotaliya\ApplePushNotificationService\ApplePushNotificationService;

    $deviceToken = 'your_device_token';
    $title = 'Hello from APNs!';
    $body = 'This is a test push notification.';

    $apns = new ApplePushNotificationService($deviceToken, $title, $body);
    $response = $apns->sendNotification();
    ```

---

### Core PHP

[](#core-php)

1. **Configuration (Required) :**

    Manually create a configuration file at `config/apns.php` in your project root directory:

    ```
