Comments (2)
Hello thank's for your question.
Get all your tokens in your database and put them in a array
And send notifications with the Facade and the method FCM::sendTo(arrayOfTokens, options, notification, data)
Following a example that I have used in my app:
$tokens = Device::pluck('fcm_token')->toArray(); // Device is a Eloquent model that contains tokens
$optionBuilder = new OptionsBuilder();
$optionBuilder->setCollapseKey('cat_detected');
$notification = new PayloadNotificationBuilder(null);
$notification->setIcon('cat_notification')
->setSound('default');
$notification->setTitleLocationKey('notification__title__cat_detected');
$notification->setBodyLocationKey('notification__body__cat_detected');
$notification->setBodyLocationArgs("[\"$detectionDate\", \"$detectionHour\"]");
$response = FCM::sendTo($tokens, $optionBuilder->build(), $notification->build());
I hope this answer will help you, and please not hesitate to contact me again if it's not working for you.
from laravel-fcm.
Hi, this way is an asynchronous method? Actually I use this in an event in Laravel 5.2, what do you think?
from laravel-fcm.
Related Issues (20)
- Laravel 7 Not Supported HOT 4
- Notification sound not working HOT 3
- Support guzzle 7.0
- send notification issue
- Change the connection on the fly
- SnederId Mismatch
- Lumen - Unable to resolve NULL driver for [LaravelFCM\FCMManager]. HOT 1
- onMessage payload not working HOT 1
- Laravel 8 HOT 6
- How to add badge on push notification using brozot/Laravel-FCM
- How to test FCM::sendTo with Feature test HOT 4
- Laravel 8 supported or not?(php 8) HOT 6
- How to send FCMGroup?
- Find exact error code or error message in responce
- How to add small icon on the right side of the notification.
- Not working on iOS devices HOT 2
- Your requirements could not be resolved to an installable set of packages. HOT 4
- Not compatible with guzzle ~7.0 HOT 1
- Not support in Laravel 9 HOT 1
- Not Support In Laravel 10 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from laravel-fcm.