Comments (11)
@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.
@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.
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.
@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.
@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.
@bimbo1989 Please post the $response from $client->send($notification) ;
@AndyGaskell - you have any thoughts on this one?
from php-fcm.
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.
@rolinger I get no $response because the exception gets thrown before getting the response from the server
from php-fcm.
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.
@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.
@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)
- Internal server error HOT 6
- FCM: Migrate from legacy HTTP to HTTP v1 HOT 7
- Documentation not consistent with composer package HOT 8
- Increase automated test coverage to 100%
- Android Notification channel id HOT 11
- Guzzle option, made a bit of a mess of the commit / merge HOT 2
- Sending to multiple topics fails HOT 4
- Improve documentation
- If you add more than five topics in FCM, the push doesn't send
- Tag a new version for Guzzle 7 HOT 5
- Optional Laravel support HOT 3
- Priority settings missing? HOT 4
- Add TTL in Notification? HOT 1
- addTopic in && non only in || HOT 9
- If you send a data only push, and empty message is sent HOT 1
- Not Registered in Results => remove device_id HOT 3
- content_available field HOT 1
- Feature request: set time out value HOT 1
- Missing collapse key HOT 5
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 php-fcm.