Skip to content

This package has the opposite of allows send push notifications for one or more devices using the firebase cloud message. Will be used CURL for communication HTTP with Firebase API on pattern REST.

License

Notifications You must be signed in to change notification settings

Pluritech/fcm-php

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Google FCM for PHP (v1)

This repository contains the open source PHP SDK that allows you to access the Google FCM Platform from your PHP app.

Installation

The Google FCM PHP SDK can be installed with Composer. Run this command:

composer require pluritech/fcm-php

Usage

Note: This version of the Google FCM SDK for PHP requires PHP 5.4 or greater.

Simple Send push example.

require_once __DIR__ . '/vendor/autoload.php'; // change path as needed

$FCMPHP = new \FCMPHP\FCMPHP([
    'fcm_server_key' => '{server-key}'
]);

$FCMNotification = new \FCMPHP\FCMNotification();

$FCMNotification->setTitle('{push-title}');
$FCMNotification->setBody('{push-description}');
$FCMNotification->setPriority('{push-priority}'); //high or normal
$FCMNotification->setDevices([ 
     '{device-id}'
    ,'{device-id}'
]); //One or more devices

$request = $FCMPHP->send($FCMNotification);

//Http error
if($request->getHttpStatusCode() != 200){
    $code = $request->getHttpStatusCode();
    $body = $request->getBody();
}

//One or more failure on send push to FCM
if($failure = $request->hasFailure()){
    $count = $failure['count'];
    $error = $failure['error'];
}

Documentation

In progress.

Tests

In progress.

Contributing

Feel free to make your pull request, chip in to suggestion or report issues.

License

MIT © Guilherme Valentim

About

This package has the opposite of allows send push notifications for one or more devices using the firebase cloud message. Will be used CURL for communication HTTP with Firebase API on pattern REST.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages