Skip to content
This repository has been archived by the owner on Sep 5, 2024. It is now read-only.

How to add badge on push notification using brozot/Laravel-FCM #205

Open
pramukhreddy opened this issue Nov 2, 2020 · 0 comments
Open

Comments

@pramukhreddy
Copy link

@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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant