PHP code example of rajchotaliya / apple-push-notification-service

1. Go to this page and download the library: Download rajchotaliya/apple-push-notification-service library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

rajchotaliya / apple-push-notification-service example snippets


      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
      

      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')),
      ];
      

   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();
   

     

     return [
         'bundle_id' => 'com.example.app',
         'key_id' => 'ABC123DEF456',
         'team_id' => 'XYZ789',
         'private_key_path' => __DIR__ . '/AuthKey.p8',
     ];
     

     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();
   
   echo $response['message'];
   

   $jwt = $apns->fetchJWT();
   
bash
      php artisan vendor:publish --provider="RajChotaliya\ApplePushNotificationService\ApplePushNotificationServiceProvider"