PHP code example of endroid / gcm

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

    

endroid / gcm example snippets


use Endroid\Gcm\Client;

$apiKey = '...';
$client = new Client($apiKey);

// Registration ID's of devices to target
$registrationIds = [
    //...
];

$data = [
    'title' => 'Message title',
    'message' => 'Message body',
];

$success = $client->send($data, $registrationIds);

// app/AppKernel.php

public function registerBundles()
{
    $bundles = [
        // ...
        new Endroid\Gcm\Bundle\EndroidGcmBundle(),
    ];
}

$client = $this->get('endroid.gcm.client');