Skip to content

bananos/adm-client

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

adm-client

Python client for Amazon Device Messaging (ADM).

Requirements

Usage

Sample usage

from admclient import ADM, flatten

client = ADM(client_id, client_secret)
# see this http://stackoverflow.com/questions/11378004/with-android-gcm-can-you-use-a-deep-json-data-field
# on why we need to flatten nested JSON structures
payload = flatten({'examplekey': {'key1': 'value1'}})
response = client.send(registration_id, payload)

# Error handling
if 'errors' in response:
    for reg_id, reason in response['errors'].items():
        if reason is 'InvalidRegistrationId':
            # Remove reg_ids from database
            pass

if 'canonical' in response:
    for reg_id, canonical_id in response['canonical'].items():
        # Replace reg_id with canonical_id in your database
        pass

Installation

pip install https://github.com/Lispython/pycurl/archive/master.zip
pip install https://github.com/Lispython/human_curl/archive/master.zip
pip install https://github.com/bananos/adm-client/archive/master.zip

This work is based on original code from Python-adm.

About

Python client for Amazon Device Messaging service

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages