Problem when notify_multiple_devices exceeds FCM_MAX_RECIPIENTS
See original GitHub issue@olucurious Thank you for providing such a solid solution for FCM. It is very cool!
I do find myself in a bit of a pickle when I use FCMNotification.notify_multiple_devices() and registration_ids
length exceeds FCM_MAX_RECIPIENTS
.
Please see the pseudo code below which illustrates the problem.
registration_ids = [...] # 2000 entries
data_message = {...}
response_list = push_service.notify_multiple_devices(
registration_ids=registration_ids, # gets chunked
data_message=data_message
)
for response in response_list:
for index, result in enumerate(response['results']):
# index lies within the index range of this chunk of registration ids
# and will only ever be between 0-999.
# Hence I've lost this association between this result and registration_ids
In order to mitigate this problem I have to employ the following workaround:
registration_ids = [...] # 2000 entries
data_message = {...}
registration_id_chunks = push_service.registration_id_chunks(registration_ids)
for chunk in registration_id_chunks:
response = push_service.notify_multiple_devices(
registration_ids=chunk,
data_message=data_message
)[0]
for index, result in enumerate(response['results']):
# now index refers to the correct registration_id within chunk
It would be nice if notify_multiple_devices() didn’t return a list of responses, but a single response. This response should be a concatenation of the chunked responses. I believe this would be a simple enough change within parse_responses
Greetings Moritz
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:14 (6 by maintainers)
Top Results From Across the Web
FCM (Firebase Cloud Messaging) Send to multiple devices
Firebase Cloud Messaging (FCM) topic messaging allows you to send a message to multiple devices that have opted in to a particular topic....
Read more >About FCM messages | Firebase Cloud Messaging - Google
Notification messages can contain an optional data payload. Maximum payload for both message types is 4000 bytes, except when sending messages from the ......
Read more >What are the limits on Firebase Cloud Messaging, I'm only ...
There are no limits to the number of notifications you can send with Firebase Cloud Message or Firebase Notifications (which is built on...
Read more >Error Messages for Push Notifications - Salesforce Help
Payload exceeds maximum size, Reduce size of payload. ; Unable to load push notifications settings, Confirm that settings are present on connected app....
Read more >Users Messages - Amazon Pinpoint
An arbitrary string that indicates that multiple messages are logically the same and that Amazon Device Messaging (ADM) can drop previously enqueued messages...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I think a simple solution is always the best. So what about creating a new function like notify_multiple_devices2 (or whatever name you’d like) with the new issue handling? and then you can even mark the previous function to be deprecated. I guess this is a typical way, isn’t it?
@Proper-Job the issue has been resolved in the new release