Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

400 Bad Request error in case of Android push #184

Open
maedamin opened this issue Aug 8, 2019 · 4 comments
Open

400 Bad Request error in case of Android push #184

maedamin opened this issue Aug 8, 2019 · 4 comments

Comments

@maedamin
Copy link

maedamin commented Aug 8, 2019

I am sure that it worked before, but recently I found the following log in laravel.log.

local.ERROR: exception 'Sly\NotificationPusher\Exception\PushException' with message '400 Bad Request; invalid message' in /mnt/home/apache/....../vendor/sly/notification-pusher/src/Sly/NotificationPusher/Adapter/Gcm.php:72

I tested it by creating a simple program, and I confirmed that it works for iOS, meaning that the contents of the message would be OK. But I faced the same error of '400' in case of Android.

I found the following source code in the server.

    public function push(PushInterface $push)
    {
        $client        = $this->getOpenedClient();
        $pushedDevices = new DeviceCollection();
        $tokens        = array_chunk($push->getDevices()->getTokens(), 100);

        foreach ($tokens as $tokensRange) {
            $message = $this->getServiceMessageFromOrigin($tokensRange, $push->getMessage());

            try {
                $this->response = $client->send($message);
            } catch (ServiceRuntimeException $e) {
                throw new PushException($e->getMessage());
            }

            if ((bool) $this->response->getSuccessCount()) {
                foreach ($tokensRange as $token) {
                    $pushedDevices->add($push->getDevices()->get($token));
                }
            }
        }

        return $pushedDevices;
    }

The error occurred at $this->response = $client->send($message);
(When I checked the source code in GitHub, and I found that the source code is slightly different. Should I update it??)

This is my first time to open an issue in GitHub, so I am not sure how I should do...
Anyway, any information is very helpful because I am now in stuck ....

@maedamin
Copy link
Author

maedamin commented Aug 8, 2019

Well. After the investigation, I found that GCM would be terminated... We need to use Firebase?
If so, how should I update it?

@maedamin
Copy link
Author

I updated the all to the new one and the error message has gone. But, push message does not reach devices though there is no error log.
I also tried $params['notificationData'] method described in #181.
(I have not changed any in Android App. It still just supports GCM.)

@centotaure
Copy link

Up ! I have exactly the same error when i send pushnotification for android !
And it's works before !!!
Have you find a solution @maedamin ?

@zeeshanaslam78
Copy link

GCM is not working anymore. It needs to update accordingly FCM.
Getting same 400 bad request error

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

No branches or pull requests

4 participants