PHP code example of manojkumarlinux / simple-apns

1. Go to this page and download the library: Download manojkumarlinux/simple-apns 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/ */

    

manojkumarlinux / simple-apns example snippets


 

mpleApns\Apns;

$config =[
    'environment' => true,
    'keyPath' => './key.pem',
    'secretKey' => 'secret Key',
    'buildId' = 'build id'
];

$message = [
    'title' => ' title ',
    'body' => 'body of message',
    'sound' => 'default' // optional
];

$deviceToken = '64-bit token';

Apns::send($config, $message, $deviceToken);


// success message 
array(2) {
  ["response"]=>
  string(8) "Success."
  ["code"]=>
  int(200)
}

// fail
array(2) {
  ["response"]=>
  string(12) "Bad request."
  ["code"]=>
  int(400)
}