All Projects → plokko → laravel-firebase

plokko / laravel-firebase

Licence: MIT License
Laravel Firebase API implementation

Programming Languages

PHP
23972 projects - #3 most used programming language

Projects that are alternatives of or similar to laravel-firebase

laravel-firebase
Laravel FCM (Firebase Cloud Messaging) Notification Channel
Stars: ✭ 25 (+13.64%)
Mutual labels:  fcm, fcm-notifications, laravel-firebase
PUSHTestFCM
[FireMonkey] Push test project
Stars: ✭ 17 (-22.73%)
Mutual labels:  fcm, fcm-notifications
FCM-OnDeviceNotificationScheduler
Demo implementation to Schedule FCM Notifications on Android Device using AlarmManager + WorkManager.
Stars: ✭ 111 (+404.55%)
Mutual labels:  fcm, fcm-notifications
Kotlin Firebase Group Chat
Group and OneonOne chat using firebase built in Kotlin similar to whatsapp.
Stars: ✭ 44 (+100%)
Mutual labels:  fcm, firebase-realtime-database
fcmpush
Firebase Cloud Messaging API wrapper for Ruby, suppot HTTP v1 API including access_token auto refresh feature.
Stars: ✭ 44 (+100%)
Mutual labels:  fcm, fcm-notifications
chatApp
This is the chat application based on Javascript, html and bootstrap. This chat app use the firebase real time database.
Stars: ✭ 15 (-31.82%)
Mutual labels:  firebase-realtime-database
FireDroid
⚡ An architectural framework for Android apps that use Firebase services 🔥
Stars: ✭ 21 (-4.55%)
Mutual labels:  firebase-realtime-database
ionicfirebasecrud
An example of crud with Firebase and Ionic
Stars: ✭ 15 (-31.82%)
Mutual labels:  firebase-realtime-database
FCMBundle
A Bundle for Symfony projects to send notifications in mobile devices through Firebase Cloud Messaging API
Stars: ✭ 43 (+95.45%)
Mutual labels:  fcm
firebase-iot-demo
🔥 ESP8266 Firebase Arduino client developed using Platformio sending DHT11 and MQ5 data to Firebase Realtime Database
Stars: ✭ 20 (-9.09%)
Mutual labels:  firebase-realtime-database
Simple-Note-App-with-Online-Storage
✍️ Simple Note Making App use Sqllite Room 🧰 for caching the notes and 📥 Firebase Database for online storage
Stars: ✭ 42 (+90.91%)
Mutual labels:  firebase-realtime-database
FirebaseDemo
Firebase realtime database demonstration with Swift, Kotlin & Dart (Flutter).
Stars: ✭ 18 (-18.18%)
Mutual labels:  firebase-realtime-database
andpush
Android Push Notification in Ruby: The fastest client for FCM (Firebase Cloud Messaging)
Stars: ✭ 83 (+277.27%)
Mutual labels:  fcm
ChatApp
Chat app based on Firebase tools.
Stars: ✭ 88 (+300%)
Mutual labels:  fcm
FirebaseChatRoom
This application shows how to build (in Swift4) a simple Chat room where users can register, login, send messages to other users etc using Firebase. If you are a developer who has got an interesting idea but could not find a backend developer to take the idea to a product level, then do check out this project as an introductory course to Firebas…
Stars: ✭ 18 (-18.18%)
Mutual labels:  firebase-realtime-database
firebase
Modular Firebase 🔥 implementation for NativeScript. Supports both iOS & Android platforms for all Firebase services.
Stars: ✭ 36 (+63.64%)
Mutual labels:  firebase-realtime-database
Java-fcm
Java wrapper library to send messages to Android clients through Firebase Cloud Messaging
Stars: ✭ 29 (+31.82%)
Mutual labels:  fcm
react-native-notifee
Moved to https://github.com/invertase/notifee
Stars: ✭ 477 (+2068.18%)
Mutual labels:  fcm
RestaurantReactApp
This is a responsive website that uses PWA app standards, completely created with React, React router and firebase
Stars: ✭ 59 (+168.18%)
Mutual labels:  firebase-realtime-database
FirebaseChatApp
A Chat app built on firebase features such as firebase-ui,database,storage and cloud messaging
Stars: ✭ 20 (-9.09%)
Mutual labels:  firebase-realtime-database

Laravel Firebase

Build Status Packagist Packagist Packagist

Laravel Firebase integration

This package includes:

  • Firebase OAuthV2.0 authentication, with token caching
  • Centralized ServiceAccount credential management
  • Firebase FCM Http V1 API and Firebase Realtime database REST api via OAuth authentication
  • Firebase JWT token generator (via php-jwt)
  • Automatic sync for Eloquent models to Firebase Realtime db
  • Automatic sync triggers on related model changes

Installation

Install via composer

composer require plokko/laravel-firebase

The package will be auto registered in laravel >=5.5; If you use laravel <5.5 follow the next two steps

  1. Add service provider to config/app.php in providers section
Plokko\LaravelFirebase\ServiceProvider::class,
  1. Register package facade in config/app.php in aliases section
Plokko\LaravelFirebase\Facades\LaravelFirebase::class,

Your file in config/laravel-firebase.php should now look like this:

<?php

return [
    'read_only' => env('FIREBASEDB_READONLY',false),//DEBUG

    /**
     * Firebase service account information, can be either:
     * - string : absolute path to serviceaccount json file
     * - string : content of serviceaccount (json string)
     * - array : php array conversion of the serviceaccount
     * @var array|string
     */
    'service_account' => base_path('.firebase-credentials.json'),

    /**
     * If set to true will enable Google OAuth2.0 token cache storage
     */
    'cache' => true,

    /**
     * Cache driver for OAuth token cache,
     * if null default cache driver will be used
     * @var string|null
     */
    'cache_driver' => null,

    /**
     * Specify if and what event to trigger if an invalid token is returned
     * @var string|null
     */
    'FCMInvalidTokenTriggerEvent' => null,
];

Configuration

Publish the configuration file via

php artisan vendor:publish --provider="Plokko\LaravelFirebase\ServiceProvider" --tag="config"

Usage

JWT token

You can easly create a Firebase JWT token (for auth) with FirebaseJWT::encode:

FirebaseJWT::encode($uid,['optional'=>'custom-claims-array']);

FCM

This package allows you to send FCM messages via FCM http v1 api

Message builder

You can easly build FCM Messages via the FCM facade:

FCM::notificationTitle('My notification title')
  ->notificationBody('my notification body...');
  ->data(['notification' => 'data'])
  ->highPriority()//note: not all devices may use all the fields like priority or ttl
  ->ttl('20.5s')
  ->toDevice('my-device-fcm-token') // or toTopic('topic-name') or toCondition('condition-name') or toTarget(Target)
  ->send();//Submits the message

FCM Notification channel

You can also send the FCM messages via the FcmNotificationChannel channel:

class TestFcmNotification extends Notification implements ShouldQueue
{
    use Queueable;
    
    /**
     * Get the notification's delivery channels.
     *
     * @param  mixed  $notifiable
     * @return array
     */
    public function via($notifiable)
    {
        return [FcmNotificationChannel::class];
    }

    public function toFcm($notifiable)
    {
        return FCM::notificationTitle('Test notification')
                    ->notificationBody('notification body...')
                    ->toDevice($notifiable->deviceToken);
    }
}

Real time database

Settings:

You can enable read-only access to database setting

FIREBASEDB_READONLY=true

on your .env file, this is usefull for testing purpuses, the writes will not return any error but will not be executed on Firebase.

Query the Realtime database

To get an instance of the database use the FirebaseDb facade:

$test = FirebaseDb::getReference('test'); //get the reference for item /test
$test->get('01');//Get /test/01 as an array
$test01 = $test->getReference('01');//Get a reference for /test/01
$test01->set('label','value');//Set /test/01/label = value

Sync models to Firebase

see Firebase database sync

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].