Python client for Google Cloud Messaging for Android (GCM)
RTFM here
gcm = GCM(API_KEY)
data = {'param1': 'value1', 'param2': 'value2'}
# Plaintext request
reg_id = '12345'
res = gcm.plaintext_request(registration_id=reg_id, data=data)
# JSON request
reg_ids = ['12', '34', '69']
res = gcm.json_request(registration_ids=reg_ids, data=data)
# Extra arguments
res = gcm.json_request(
registration_ids=reg_ids, data=data,
collapse_key='uptoyou', delay_while_idle=True, time_to_live=3600
)
# Handle responses. This raises exceptions when GCM servers return errors
gcm.handle_response(res)
Read more on response errors here
- GCMMalformedJsonException
- GCMConnectionException
- GCMAuthenticationException
- GCMTooManyRegIdsException
- GCMNoCollapseKeyException
- GCMInvalidTtlException
- GCMMissingRegistrationException
- GCMMismatchSenderIdException
- GCMNotRegisteredException
- GCMMessageTooBigException