This repository was archived by the owner on Sep 5, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 409
How to add badge on push notification using brozot/Laravel-FCM #205
Copy link
Copy link
Open
Description
@brozot ----> Please Help
How to add badge on push notification using brozot/Laravel-FCM ?
I'm sending and receiving push notifications correctly on iOS devices, but I would like to know how can I send badge information with the notification builder?
I tried this code but it is not working (see error below):
`$optionBuilder = new OptionsBuilder();
$optionBuilder->setTimeToLive(43200);
$notificationBuilder = new PayloadNotificationBuilder();
$notificationBuilder->setBody($payload['notificationmessage'])
->setImage($payload['imageurl'])
->setBadge($payload['badgecount']);
$dataBuilder = new PayloadDataBuilder();
$dataBuilder->addData(['device_data' => $payload]);
$option = $optionBuilder->build();
$notification = $notificationBuilder->build();
$data = $dataBuilder->build();
$downstreamResponse = FCM::sendTo($value->device_token, $option, $notification, @$data);
But it is throwing following error
[2020-11-02 04:49:28] local.ERROR: Symfony\Component\Debug\Exception\FatalThrowableError: Call to a member function setBadge() on string in /var/www/html/app/Http/Controllers/api/v1/NotificationsController.php:221
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels