承接 mowahed/firebase-notification 相关项目开发

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

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

mowahed/firebase-notification

最新稳定版本:2.0.2

Composer 安装命令:

composer require mowahed/firebase-notification

包简介

Laravel package for Firebase Cloud Messaging

README 文档

README

A comprehensive Laravel package for sending Firebase Cloud Messaging (FCM) push notifications to devices, topics, and conditions.

Features

  • Send notifications to individual devices
  • Send notifications to topics
  • Subscribe/unsubscribe devices from topics
  • Send notifications based on conditions
  • Comprehensive error logging
  • Support for all FCM features (images, sounds, deep links, etc.)

Installation

  1. Install via Composer:
composer require mowahed/firebase-notification:^2.0.2

php artisan vendor:publish --tag=firebase-config

Add This in .env

FIREBASE_PROJECT_ID="your-project-id"
FIREBASE_CREDENTIALS="app/firebase/service-account-key.json"
FIREBASE_LOGGING_ENABLED="true"
FIREBASE_LOGGING_CHANNEL="firebase"

Add this in logging.php

 'channels' => [
    'firebase' => [
        'driver' => 'single',
        'path' => storage_path('logs/firebase.log'),
        'level' => 'error',
    ],
],

2. Send Notification to Device

use Mowahed\FirebaseNotification\Facades\FirebaseNotification;

$response = FirebaseNotification::sendToDevice('device_fcm_token', [
    'title' => 'Welcome!',
    'body' => 'Thanks for installing our app!',
    'link' => 'https://yourapp.com',
    'sound' => 'default',
    'image' => 'https://example.com/notification.png',
    'priority' => 'high'
]);

3. Send Notification to Topic

FirebaseNotification::sendToTopic('news,' [
    'title' => 'Breaking News',
    'body' => 'Something big just happened!',
    'link' => 'https://yourapp.com/news',
    'sound' => 'default'
]);

4. Subscribe Device to Topic

$response = FirebaseNotification::subscribeToTopic(
    ['device_token_1', 'device_token_2'],
    'news'
);

5. Send Notification to Condition

$response = FirebaseNotification::sendToCondition(
    "'sports' in topics || 'news' in topics",
    [
        'title' => 'Sports News',
        'body' => 'Latest sports updates!',
        'link' => 'https://yourapp.com/sports'
    ]
);

6. Unsubscribe Device from Topic

$response = FirebaseNotification::unsubscribeFromTopic(
    ['device_token_1', 'device_token_2'],
    'news'
);

统计信息

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

GitHub 信息

  • Stars: 5
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-05-15