承接 riftweb/firebase-notifications 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

riftweb/firebase-notifications

Composer 安装命令:

composer require riftweb/firebase-notifications

包简介

Effortlessly manage Firebase Cloud Messaging (FCM) notifications in your Laravel applications. This package simplifies sending FCM notifications with a clean and intuitive API, making it easy to integrate push notifications into your projects.

README 文档

README

Latest Version Total Downloads License Website

A Laravel package that lets you use the new FCM Http V1 API and send push notifications with ease.

Summary

  1. Install
  2. Usage

Install

If your Firebase project is already configured, skip this part and go to the Usage section section.

Firebase

TBD

Laravel

  1. Install via Composer
composer require riftwebdev/firebase-notifications
  1. Publish the config file
php artisan vendor:publish --tag=firebase-notifications --ansi --force
  1. Place your Firebase JSON on your project.

    image
  2. Retrieve the .env variables from your Firebase Console -> Project Settings -> General and watch firebaseConfig.

    5
  3. Assign values to the .env variables

FCM_API_KEY="<Firebase apiKey>"
FCM_AUTH_DOMAIN="<Firebase authDomain>"
FCM_PROJECT_ID="<Firebase projectId>"
FCM_STORAGE_BUCKET="<Firebase storageBucket>"
FCM_MESSAGING_SENDER_ID="<Firebase messagingSenderId>"
FCM_APP_ID="<Firebase appId>"
FCM_JSON="<path of the JSON file from Firebase>"

Usage

Topics

Topics are used to make groups of device tokens. They will allow you to send notification directly to the topic where users are registered in.

Subscribe

Single Token to Single Topic
use Riftweb\FirebaseNotifications\Facades\FcmTokenTopic;

$token = "example token";
$topic = "exampleTopic";

FcmTokenTopic::subscribeToTopic($token, $topic);
Multiple Tokens to Single Topic
use Riftweb\FirebaseNotifications\Facades\FcmTokenTopic;

$tokens = ["example token 1", "example token 2"];

$topic = "exampleTopic";

FcmTokenTopic::subscribeToTopic($tokens, $topic);
Single Token to Multiple Topics
use Riftweb\FirebaseNotifications\Facades\FcmTokenTopic;

$token = "example token";
$topics = ["exampleTopic1", "exampleTopic2"];

FcmTokenTopic::subscribeToTopics($token, $topics);
Multiple Tokens to Multiple Topics
use Riftweb\FirebaseNotifications\Facades\FcmTokenTopic;

$tokens = ["example token 1", "example token 2"];
$topics = ["exampleTopic1", "exampleTopic2"];

FcmTokenTopic::subscribeToTopics($tokens, $topics);

Unsubscribe

Single Token to Single Topic
use Riftweb\FirebaseNotifications\Facades\FcmTokenTopic;

$token = "example token";
$topic = "exampleTopic";

FcmTokenTopic::unsubscribeToTopic($token, $topic);
Multiple Tokens to Single Topic
use Riftweb\FirebaseNotifications\Facades\FcmTokenTopic;

$tokens = ["example token 1", "example token 2"];

$topic = "exampleTopic";

FcmTokenTopic::unsubscribeToTopic($tokens, $topic);
Single Token to Multiple Topics
use Riftweb\FirebaseNotifications\Facades\FcmTokenTopic;

$token = "example token";
$topics = ["exampleTopic1", "exampleTopic2"];

FcmTokenTopic::unsubscribeToTopics($token, $topics);
Multiple Tokens to Multiple Topics
use Riftweb\FirebaseNotifications\Facades\FcmTokenTopic;

$tokens = ["example token 1", "example token 2"];
$topics = ["exampleTopic1", "exampleTopic2"];

FcmTokenTopic::unsubscribeToTopics($tokens, $topics);

List Token Subscribed Topics

use Riftweb\FirebaseNotifications\Facades\FcmTokenTopic;

$token = "example token 1";

FcmTokenTopic::getTopics($token);

Notification

You can send notification to specific tokens or to topics, and both at same time.

Beware, if you set topics and tokens at same time, both will receive (whoever is subscribed to the topics + the extra tokens

use Riftweb\FirebaseNotifications\Facades\FcmNotification;

FcmNotification::create()
  ->setTitle('Example Notification')
  ->setBody('Lorem ipsum dolores')
  ->setImage(asset('images/example.png'))
  ->setCategory('develop') // Compatible with iOS
  ->setSound('blingbling') // Compatible with iOS
  ->setFlutterClickAction() // Only use this if you're using flutter - Will set click_action as FLUTTER_NOTIFICATION_CLICK, otherwise use setClickAction()
  ->setLink('https://example.com') // Used for webpush notifications
  ->setData([
    'user_id' => 1,
    'foo' => 'bar'
  ]) // Extra Data
  ->setTopics(['topic 1', 'topic 2']) // Set this notification to be sent for certain topics
  ->setTokens(['token 1', 'token 2']) // Specify which tokens will receive this notification
  ->send();

Notification Mapping

 return [
            "notification" => [
                "title" => $this->title,
                "body" => $this->body,
                'image' => $image, // Used by Android/iOS
            ],
            "data" => $this->data,
            "android" => [
                "notification" => [
                    "click_action" => $this->click_action
                ]
            ],
            "apns" => [
                "payload" => [
                    "aps" => [
                        "category" => $this->category,
                        "sound" => $this->sound
                    ]
                ],
                "fcm_options" => [
                    "image" => $image,
                ]
            ],
            "webpush" => [
                "notification" => [
                    "title" => $this->title,
                    "body" => $this->body,
                    "icon" => $image,
                ],
                "fcm_options" => [
                    "link" => $this->link
                ]
            ]
        ];

Contributing 🤝

Contributions are welcome! Please follow:

  1. Fork the repository
  2. Create your feature branch
  3. Commit changes
  4. Push to the branch
  5. Open a PR

License 📄

MIT License - See LICENSE for details.

riftweb/firebase-notifications 适用场景与选型建议

riftweb/firebase-notifications 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 0 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 07 月 30 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「notifications」 「laravel」 「push notifications」 「firebase」 「FCM」 「Firebase Cloud Messaging」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 riftweb/firebase-notifications 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 riftweb/firebase-notifications 我们能提供哪些服务?
定制开发 / 二次开发

基于 riftweb/firebase-notifications 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 0
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 28
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-07-30