PHP code example of napp / aerogear-push

1. Go to this page and download the library: Download napp/aerogear-push 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/ */

    

napp / aerogear-push example snippets


$request->setOauthToken($token);



use Napp\AeroGearPush;
use Napp\AeroGearPush\Request;
use Napp\AeroGearPush\Exception;

$client = new AeroGearPush('https://host.com/ag-push/rest/');

$request = new SenderPushRequest();
$request
->setAuth('PushApplicationID', 'MasterSecret')
->setMessage(
  [
    'sound' => 'default',
    'alert' => 'this is a message.',
  ]
)
->setCriteria(
  [
    'alias' => ['my-alias'],
  ]
);

try {
  $response = $client->SenderPush($request);
  var_dump($response);
} catch (AeroGearPushException $e) {
  die($e->getMessage());
}
setCertificate() # fopen file resource