vyconsulting-group / push-notification
PHP wrapper FCM
Installs: 4 408
Dependents: 0
Suggesters: 0
Security: 0
Stars: 15
Watchers: 2
Forks: 1
pkg:composer/vyconsulting-group/push-notification
Requires
- php: >=5.3.0
README
wetillix/push-notification is a simple and efficient PHP package for sending notifications via Firebase Cloud Messaging (FCM).
Installation
Install the package via Composer:
composer require wetillix/push-notification
Configuration
After installation, prepare your firebase_credentials.json file containing your FCM credentials. Store this file securely in your project.
Usage
Initialization
Import and initialize the service in your project, providing the path to the FCM credentials file in the constructor:
use Wetillix\PushNotification\PushNotification; $pushNotification = new PushNotification('/path/to/firebase_credentials.json');
Sending a Notification to a Specific Device
Use the sendPushNotificationToDevice method to send a notification to a user:
$response = $pushNotification->sendPushNotificationToDevice( token: 'device_token', data: [ 'title' => 'value1', 'description' => 'value2' ] );
Sending a Notification to a Topic
Use the sendPushNotificationToTopic method to send a notification to all users subscribed to a topic:
$response = $pushNotification->sendPushNotificationToTopic( topic: 'topic_name', data: [ 'title' => 'value1', 'description' => 'value2' ] );
Contribution
Contributions are welcome! Follow these steps:
- Fork the project.
- Create a new branch:
git checkout -b my-branch. - Make your changes.
- Submit a Pull Request.
License
This project is licensed under the MIT license.