kongkannika/google-cloud-messaging-php

There is no license information available for the latest version (dev-master) of this package.

Push Notification to Google Cloud Messaging PHP for Android

dev-master 2015-09-30 06:52 UTC

This package is not auto-updated.

Last update: 2024-05-11 16:23:36 UTC


README

Push Notification to Android device by using PHP.

How to use?

  • To push a message to many devices :
<?php
	include_once 'GoogleCloudMessaging.php';
	$registerationIds = array(
		'APA91bH-lf7YXuGvkD1-iCtcgSr4vrWbqkxIz1idD_VGzcLiUSqJd...',
		'APA91bFUvwEtgOMQcqXVn06jheApvsZAQ2KSsZrPQSdRzO5eadU4E...',
		'APA91bGZT_5uyha9nRnWZnUf6OcL_c971Pd4ckAceQPfJ3b57NhhC...',
		//...
	);
	$data = array(
		'id' => 1000,
		'message' => "Hello Android! You've got a message from me ^_^",
		'url' => 'http://www.google.com',
		//...
	);
	$gcm = new GoogleCloudMessaging('GCM_API_KEY');
	$gcm->pushMessageToManyDevices($registerationIds, $data);
?>
  • To push a message to a device :
<?php
	include_once 'GoogleCloudMessaging.php';
	$registerationId = 'APA91bH-lf7YXuGvkD1-iCtcgSr4vrWbqkxIz1idD_VGzcLiUSqJd...';
	$data = array(
		'id' => 1000,
		'message' => "Hello Android! You've got a message from me ^_^",
		'url' => 'http://www.google.com',
		//...
	);
	$gcm = new GoogleCloudMessaging('GCM_API_KEY');
	$gcm->pushMessageToOneDevice($registerationId, $data);
?>

How to get API Key?

http://developer.android.com/google/gcm/gs.html

DONE!