PHP code example of coreproc / gcm

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

    

coreproc / gcm example snippets




oreproc\Gcm\GcmClient;
use Coreproc\Gcm\Classes\Message;

$gcmClient = new GcmClient('your-gcm-api-key-here');

$message = new Message($gcmClient);

$message->addRegistrationId('xxxxxxxxxx');
$message->setData([
    'title' => 'Sample Push Notification',
    'message' => 'This is a test push notification using Google Cloud Messaging'
]);

// More options are available in the Message class

try {
    
    $response = $message->send();
    
    // The send() method returns a Response object
    print_r($response);
    
} catch (Exception $exception) {
    
    echo 'uh-oh: ' . $exception->getMessage();
    
}