muneebkh2/laravel-fcm-notifications
最新稳定版本:1.0.5
Composer 安装命令:
composer require muneebkh2/laravel-fcm-notifications
包简介
Laravel package for sending push notifications using Firebase Cloud Messaging (FCM).
README 文档
README
A Laravel package for sending push notifications using Firebase Cloud Messaging (FCM).
Installation
You can install the package via Composer:
composer require muneebkh2/laravel-fcm-notifications
Publish the Configuration
The configuration file will be automatically published. If you need to manually publish it, you can run:
php artisan vendor:publish --provider="Muneebkh2\LaravelFcmNotifications\FCMServiceProvider" --tag="config"
Configuration
Add your Firebase credentials and project ID to the .env file:
FIREBASE_CREDENTIALS=/path/to/your/firebase_credentials.json FIREBASE_PROJECT_ID=your-firebase-project-id
Usage
You can use the FCM facade to send notifications. Here’s an example:
<php use Muneebkh2\LaravelFcmNotifications\Facades\LaravelFCM; LaravelFCM::sendNotification($deviceToken, 'Test Title', 'Test Body');
Example Controller
Here’s an example of how you might use the package in a controller:
<?php namespace App\Http\Controllers; use Illuminate\Http\Request; use Muneebkh2\LaravelFcmNotifications\Facades\LaravelFCM; class NotificationController extends Controller { public function sendPushNotification(Request $request) { $deviceToken = $request->input('device_token'); $title = $request->input('title'); $body = $request->input('body'); LaravelFCM::sendNotification($deviceToken, $title, $body); return response()->json(['message' => 'Notification sent successfully']); } }
统计信息
- 总下载量: 401
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-10-07