elmogy/fcm

A Laravel package for FCM (Firebase Cloud Messaging) integration.

v1.4 2025-04-21 07:45 UTC

This package is auto-updated.

Last update: 2025-05-21 07:58:06 UTC


README

alt tag

elmogy/fcm

A Laravel package for FCM (Firebase Cloud Messaging) integration .

Features

  • Easy integration with Laravel applications

Requirements

  • PHP 8.0
  • apiclient ^2.0

Installation

composer require elmogy/fcm

Configuration:

# Elmogy Fcm Configuration for Production Environment (.env)
FIREBASE_PROJECT_ID=YOUR_PROJECT_ID
FIREBASE_FILE=FIREBASE_FILE

Instantiating FCM Class

To begin using the FCM functionality, you need to instantiate the elmogy/fcm class. Follow these steps:

Step 1: Import FCM Class

Before you can create an instance of the elmogy/fcm class, ensure that you import it into your PHP file using the use statement:

use elmogy\fcm\FCMService;

Step 2: Instantiate FCM Class

Once the class is imported, you can instantiate it using the following code:

 $fcmService = new FCMService();

This creates an instance of the FCM class, allowing you to utilize its methods and properties for handling FCM within your Laravel application.

How to use :

1 - checkout & session

  • Create session :
    use elmogy\fcm\FCMService;

    $fcmService = new FCMService();

    $fcmToken = "DEVICE_TOKEN"; // Replace with the actual FCM token
    $title    = "Test Notification";
    $body     = "This is a test message.";
    $icon     = "/default.png"; // Optional
    $data     = ['key' => 'value'] ; // Optional

    $response = $fcmService->sendFCM($fcmToken, $title, $body , $icon ,$data);