PHP Classes

File: testPush.php

Recommend this page to a friend!
  Classes of Christiaan Baartse   PHP Google Cloud Messaging Server   testPush.php   Download  
File: testPush.php
Role: Example script
Content type: text/plain
Description: Example script
Class: PHP Google Cloud Messaging Server
Send messages to Android applications using GCM
Author: By
Last change:
Date: 11 years ago
Size: 494 bytes
 

Contents

Class file image Download
<?php
include 'vendor/autoload.php';

class
EchoLogger extends \Psr\Log\AbstractLogger
{
    public function
log($level, $message, array $context = array())
    {
        echo
sprintf('%s: %s'.PHP_EOL, $level, $message);
    }
}

$sender = new \WebPower\gcm\server\Sender('api key');
$sender->setLogger(new EchoLogger());

$message = \WebPower\gcm\server\Message::builder();
$message->addData('message', 'Hoi');

$result = $sender->singleSendNoRetry($message->build(), 'reg Id');

echo
$result;