PHP code example of peterujah / php-firebase-notification
1. Go to this page and download the library: Download peterujah/php-firebase-notification 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/ */
peterujah / php-firebase-notification example snippets
use Peterujah\NanoBlock\FirebaseServiceModel;
use Peterujah\NanoBlock\FirebaseService;
define("GOOGLE_FCM_API_KEY", "AAAAtXpvsYU:APXXX");
$model = new FirebaseServiceModel();
$service = new FirebaseService(GOOGLE_FCM_API_KEY);
$model->setTo("f-bbVq2uCgY:APA91bF0s7jk5lXXy");
$model->setTitle("I code it here");
$model->setMessage("Will you like to join us?");
$response = $service->notify($model);
var_export($response);
$model->setTo(array("User-A", "User-B", "User-C"));
$model->setTitle("I code it here");
$model->setMessage("Will you like to join us?");
$response = $service->notify($model);
var_export($response);
$model->setIsTopic(FirebaseServiceModel::TOPIC);
$model->setTo("TOPIC_GROUP_ID_NAME");
$model->setTitle("I code it here");
$model->setMessage("Will you like to join us?");
$response = $service->notify($model);
var_export($response);