https://github.com/redjanym/php-firebase-cloud-messaging
PHP API for Firebase Cloud Messaging from Google
https://github.com/redjanym/php-firebase-cloud-messaging
android fcm google-firebase hacktoberfest ios notifications
Last synced: 4 days ago
JSON representation
PHP API for Firebase Cloud Messaging from Google
- Host: GitHub
- URL: https://github.com/redjanym/php-firebase-cloud-messaging
- Owner: redjanym
- License: mit
- Fork: true (sngrl/php-firebase-cloud-messaging)
- Created: 2017-02-25T16:53:02.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2022-07-14T18:59:25.000Z (about 3 years ago)
- Last Synced: 2025-01-19T08:16:29.023Z (9 months ago)
- Topics: android, fcm, google-firebase, hacktoberfest, ios, notifications
- Language: PHP
- Homepage:
- Size: 42 KB
- Stars: 35
- Watchers: 3
- Forks: 21
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# PHP Firebase Cloud Messaging
PHP SDK for Firebase Cloud Messaging from Google, supporting HTTP V1.
See original Firebase docs: https://firebase.google.com/docs/
#Setup
Install via Composer:
```
composer require redjanym/php-firebase-cloud-messaging
```Or add this to your composer.json and run "composer update":
```
"require": {
"redjanym/php-firebase-cloud-messaging": "2.*"
}
```# Send message to a Device
```
use RedjanYm\FCM\Client;
use RedjanYm\FCM\Notification;
use RedjanYm\FCM\Recipient\Device;$serviceAccountPath = '/path/to/service-account.json';
$testToken = 'this-is-a-token';$client = new Client($serviceAccountPath);
$recipient = new Device($testToken);
$notification = new Notification($recipient, 'Title', 'Body', ['key' => 'value']);$client->send($notification);
```# Topic Support
The current version does not have support for Topics. We are going to add it on v2.1.# Migrating from V1.
Unfortunately V2 of this package introduces breaking changes. But the new structure of the SDK is still simple and very similar to the previous one. We are sure the migration is going to be very fast and easy.# Interpreting responses
Responses given on the HTTP requests are standard according to the FCM documentations. You may find detailed specifications in this links:
* https://firebase.google.com/docs/cloud-messaging/http-server-ref#interpret-downstream
* https://firebase.google.com/docs/cloud-messaging/http-server-ref#error-codes