Git Product home page Git Product logo

Comments (11)

rolinger avatar rolinger commented on June 3, 2024

@bimbo1989 - interesting. Will look into this and get back. Currently header Content-Length: is not an option that can be set. But also not certain why you are getting it either. No one else has reported this and I have not seen this issue or error before. I thought maybe it was a new requirement for FCM but doing a quick google search shows that others have experienced this problem over the past 2 to 3 years using different FCM methods. So its not a new thing that is causing php-fcm to break.

from php-fcm.

rolinger avatar rolinger commented on June 3, 2024

@bimbo1989 - can you post your $my_title and $my_message values you are testing with?

Check that the total size of the payload data included in a message does not exceed FCM limits: 4096 bytes for most messages, or 2048 bytes in the case of messages to topics. This includes both the keys and the values.

from php-fcm.

bimbo1989 avatar bimbo1989 commented on June 3, 2024

Hi @rolinger , thank you for getting back to me.
I tried sending very short strings, both for title and for message, much shorter than 2048 bytes. The longest thing I'm sending is the API key, that is 174 bytes long.

from php-fcm.

rolinger avatar rolinger commented on June 3, 2024

@bimbo1989 - upon further review it looks like you are mixing methods.

addTopic does not exist. Not even for subscribing to a new topic.

To send an actual notification it would be:

    $notification
        ->addRecipient('/topics/' .$my_topic)
        ->setTitle($subject)
        ->setBody($msg)
        ->setSound("default")
        ->setColor($customColor)
        ->setIcon("notification_icon") ;

If you were sending to a specific deviceID it would be:
$notification->addRecipient($deviceID) ;

from php-fcm.

bimbo1989 avatar bimbo1989 commented on June 3, 2024

@rolinger ok, I removed the addTopic and replaced it with addRecipient as you suggested (sorry for that mistake) but unluckily I still get the same 411.
This is a print_r of the $notification variable before sending it.

Fcm\Push\Notification Object
(
    [title:Fcm\Push\Notification:private] => Notifiche push
    [body:Fcm\Push\Notification:private] => Benvenuto!
    [recipients:Fcm\Push\Notification:private] => Array
        (
            [0] => /topics/my_topic_name
        )

    [topics:Fcm\Push\Notification:private] => Array
        (
        )

    [data:Fcm\Push\Notification:private] => Array
        (
        )

)

Do I need to add something else?

from php-fcm.

rolinger avatar rolinger commented on June 3, 2024

@bimbo1989 Please post the $response from $client->send($notification) ;

@AndyGaskell - you have any thoughts on this one?

from php-fcm.

bimbo1989 avatar bimbo1989 commented on June 3, 2024

It might be interesting to add that everything was working fine while in localhost, using the web API key.
Then I deployed to production and... 411. First I had a different error because I was still using the Web API key, the 411 began to appear when I used the Cloud Messaging server key.
Did I do something wrong there? I'm sure it's not your fault, I must be doing something very stupid being a newbie when it comes to Firebase 😅

from php-fcm.

bimbo1989 avatar bimbo1989 commented on June 3, 2024

@rolinger I get no $response because the exception gets thrown before getting the response from the server

from php-fcm.

rolinger avatar rolinger commented on June 3, 2024

Are you trying:
$reponse = $client->send($notificaiton) ;

The error would then be like: $response['results'][0]['error']

Well, its def not my fault, because mine works just fine. :-) However, if you had it working with localhost, then my guess is you have something else going on. Verify your serverID and tokenIDs - and that your production server (domain) is allowed to use those keys.

from php-fcm.

bimbo1989 avatar bimbo1989 commented on June 3, 2024

@rolinger no $response either because the exception is thrown inside send() so it does not return anything. I'll try and check the IDs and let you know

from php-fcm.

bimbo1989 avatar bimbo1989 commented on June 3, 2024

@rolinger I solved!
I just generated a new server key and it worked flawlessly. The weird thing is that the new one has no differences compared to the first. Oh well!
I'm really sorry for wasting your time, but I hope that this thread might help someone in the future :)

from php-fcm.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.