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

v1.8 2022-10-30 16:26 UTC

This package is auto-updated.

Last update: 2025-10-29 02:09:39 UTC


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:

  1. Fork the project.
  2. Create a new branch: git checkout -b my-branch.
  3. Make your changes.
  4. Submit a Pull Request.

License

This project is licensed under the MIT license.