@@ -100,7 +100,7 @@ def send(message, dry_run=False, app=None):
100
100
return _get_messaging_service (app ).send (message , dry_run )
101
101
102
102
def send_all (messages , dry_run = False , app = None ):
103
- """Batch sends the given messages via Firebase Cloud Messaging (FCM) .
103
+ """Sends the given list of messages via Firebase Cloud Messaging as a single batch .
104
104
105
105
If the ``dry_run`` mode is enabled, the message will not be actually delivered to the
106
106
recipients. Instead FCM performs all the usual validations, and emulates the send operation.
@@ -258,10 +258,7 @@ class BatchResponse(object):
258
258
259
259
def __init__ (self , responses ):
260
260
self ._responses = responses
261
- self ._success_count = 0
262
- for response in responses :
263
- if response .success :
264
- self ._success_count += 1
261
+ self ._success_count = len ([resp for resp in responses if resp .success ])
265
262
266
263
@property
267
264
def responses (self ):
@@ -455,7 +452,7 @@ def _message_data(self, message, dry_run):
455
452
456
453
def _postproc (self , resp , body ):
457
454
if resp .status == 200 :
458
- return json .loads (body )
455
+ return json .loads (body . decode () )
459
456
else :
460
457
raise Exception ('unexpected response' )
461
458
@@ -498,7 +495,7 @@ def _parse_batch_error(self, error):
498
495
499
496
data = {}
500
497
try :
501
- parsed_body = json .loads (error .content )
498
+ parsed_body = json .loads (error .content . decode () )
502
499
if isinstance (parsed_body , dict ):
503
500
data = parsed_body
504
501
except ValueError :
0 commit comments