-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update push notifications library to migrate GCM to http v1
- Loading branch information
Showing
6 changed files
with
90 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -212,3 +212,4 @@ supervisord.pid | |
# exclude pem certificates | ||
**.pem | ||
images | ||
compose/firebase-admin-credentials.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
from firebase_admin import messaging | ||
|
||
def parse_gcm_response(gcm_response): | ||
if isinstance(gcm_response, messaging.BatchResponse): | ||
return [parse_gcm_response(resp) for resp in gcm_response.responses] | ||
|
||
if isinstance(gcm_response, messaging.SendResponse): | ||
return { | ||
"success": gcm_response.success, | ||
"msg_id": gcm_response.message_id, | ||
"exception":gcm_response.exception, | ||
} | ||
return gcm_response | ||
|
||
def has_successful_response(gcm_send_response, apns_send_response): | ||
if isinstance(gcm_send_response, Exception) and isinstance(apns_send_response, Exception): | ||
return False | ||
|
||
if isinstance(gcm_send_response, list): | ||
for gcm_response in gcm_send_response: | ||
if isinstance(gcm_response, messaging.BatchResponse) and gcm_response.success_count > 0: | ||
return True | ||
elif isinstance(gcm_response, messaging.SendResponse) and gcm_response.success: | ||
return True | ||
elif isinstance(gcm_response, dict) and gcm_response.get("success"): | ||
return True | ||
|
||
if isinstance(apns_send_response, list): | ||
for apns_response in apns_send_response: | ||
if not isinstance(apns_response, dict): | ||
continue | ||
if any([result == 'Success' for result in apns_response.values()]): | ||
return True | ||
|
||
return False | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters