定制 digimantra/digi-notification 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

digimantra/digi-notification

最新稳定版本:v1.0.2

Composer 安装命令:

composer require digimantra/digi-notification

包简介

A Laravel package to send FCM push notification.

README 文档

README

Packagist Version Packagist Downloads GitHub License

This package provides an easy way to send Firebase Cloud Messaging (FCM) push notifications in Laravel applications using Google's Firebase API.

Table of Contents

Requirements

  • Laravel 8, 9, or 10
  • PHP 8.0 or higher
  • Google API Client (installed automatically via composer)
  • Firebase account with Cloud Messaging API enabled

Installation

  1. Install via Composer

    composer require digimantra/digi-notification
  2. Publish Configuration

    php artisan vendor:publish --tag=config --provider="DigiNotification\FcmHelper\FcmServiceProvider"
  3. Set Up Environment Variables

    Add the following to your .env file:

    FIREBASE_PROJECT_ID=your-firebase-project-id
    FIREBASE_CREDENTIALS=path/to/your/credentials.json

    You can generate the credentials file from the Firebase Console.

Usage

Sending FCM Notifications:

### Use Namespaces
use DigiNotification\FcmHelper\FcmHelper; 

### Assigning variables 
$tokens = ['device_token_1', 'device_token_2']; // Array of device tokens to which the notification will be sent.
$title = 'New Notification'; // The title of the notification.
$body = 'This is the body of the notification'; // The body content of the notification.
$data = ['key' => 'value']; // (Optional) Additional custom data.

### Example Send FCM notificaiton Dispatch
FcmHelper::sendFcmNotification($tokens, $title, $body, $data);  

Configuration

Queue Configuration

Ensure your queue system is set up properly by adding the following to your `.env` file:

env

QUEUE_CONNECTION=database

Then, create the jobs table and run the migration:

php artisan queue:table
php artisan migrate

Logging

To enable logging, add this to your .env file:

FCM_LOGGING=true
Set to false to disable logging.

Known Issues

Ensure FCM tokens are valid, as invalid tokens might cause delivery failures.
Invalid service account credentials will cause the package to fail to obtain an access token from Firebase.

License

This package is open-sourced under the MIT license.

Support

For support or more details you can reach out at it@digimantra.com.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-09-20