aliamassi/fcm-notification
Composer 安装命令:
composer require aliamassi/fcm-notification
包简介
Laravel package to send Firebase Cloud Messaging notifications to Android and iOS.
README 文档
README
Laravel package to send Firebase Cloud Messaging (FCM) notifications to Android and iOS devices.
Requirements
- PHP 8.0 or higher
- Laravel 8/9/10
- google/auth ^1.20
- guzzlehttp/guzzle ^7.0 fileciteturn1file3
Installation
composer require aliamassi/fcm-notification dev-main
If you want to publish the configuration file, run:
php artisan vendor:publish --provider="AliAmassi\FcmNotification\FirebaseNotificationServiceProvider" --tag="config"
Configuration
Copy your Firebase service account JSON to storage/app/firebase-service-account.json or set the path in your .env:
FIREBASE_CREDENTIALS=/full/path/to/firebase-service-account.json FIREBASE_PROJECT_ID=your-firebase-project-id
The default config values are defined in config/fcm.php. After publishing, you can find the file at config/fcm.php.
Usage
Use the FirebaseNotification facade or inject AliAmassi\FcmNotification\FirebaseClient.
Sending a Single Notification
use FirebaseNotification; $response = FirebaseNotification::send( 'device-token', [ 'title' => 'Hello', 'body' => 'This is a test notification', ], [ 'foo' => 'bar' ] );
Sending to Multiple Devices
$tokens = ['token1', 'token2', 'token3']; $response = FirebaseNotification::send( $tokens, ['title' => 'Batch Title', 'body' => 'Batch Body'] );
The client implementation handles obtaining and caching the access token via OAuth2 using your service account credentials fileciteturn1file5.
Publishing to Packagist
-
Tag your release:
git tag v1.0.0 git push --tags
-
Submit your repository on Packagist.
Contributing
Contributions are welcome! Please submit issues and pull requests.
License
MIT License. See the LICENSE file.
统计信息
- 总下载量: 18
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 4
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-07-01