A PHP Library for Apple Push Notification Service
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


Apple Push Notification Service via PHP

A PHP Library for Apple Push Notification Service


  • Send Push Notification
  • Customise as JSON Payload


  1. Device Token which you will get as callback (in AppDelegate.swift) when you register for Push Notification.
  2. PEM Certificate of your app which you get from Apple Developer Portal.


You can install apnsPHP via Composer. First, add composer.json file in your project

  "require": {
    	"apns/apnsPHP": "*"

And, install dependencies by command

composer install


  1. Send Push Notification when you've text only

I'm assuming you have pem certificate with you.

//Path of Certfiicate
$pathOfCertificate = $_SERVER['DOCUMENT_ROOT']."/certificate.pem";

// Initialise APNS
$apns = new apnsPHP($pathOfCertificate);
$apns->sendPushNotification("This is my Message", $token);
  1. Send Push Notification when you've complete JSON Payload

As, Apple Push Notification payload looks like this where, alert is the push-notification message, badge is the badge number which comes on AppIcon in numeric form with red bubble and last is sound which is alert tone when push notification pops.

    "alert" : "Hello World :D",
    "badge" : 1,
    "sound" : "default"

So, you have to first prepare the payload and then call apns defined method,

// Token
$token = "FCFFA7C61D647BA62DAxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";

// Associative Array
$payload['aps'] = array('alert' => 'Hello World :D', 'badge' => 1, 'sound' => 'default');

// Convert Array into JSON
$payloadJSON = json_encode($payload);

And, last you have to call APNS method.

$apns = new apnsPHP($pathOfCertificate);
$apns->sendPushNotification($payloadJSON, $token);


You can refer Apple Documentation for Apple Push Notification Service.