digimantra/digi-notification
最新稳定版本:v1.0.2
Composer 安装命令:
composer require digimantra/digi-notification
包简介
A Laravel package to send FCM push notification.
README 文档
README
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
-
Install via Composer
composer require digimantra/digi-notification
-
Publish Configuration
php artisan vendor:publish --tag=config --provider="DigiNotification\FcmHelper\FcmServiceProvider" -
Set Up Environment Variables
Add the following to your
.envfile: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
其他信息
- 授权协议: MIT
- 更新时间: 2024-09-20