Push notifications for APNS (iOS) and GCM (Android).
Project description
Push notifications for APNS (iOS) and GCM (Android).
Links
Project: https://github.com/dgilland/pushjack
Documentation: http://pushjack.readthedocs.org
TravisCI: https://travis-ci.org/dgilland/pushjack
Quickstart
Whether using APNS or GCM, pushjack provides a common API interface for each.
APNS
from pushjack import APNSClient, create_apns_config
config = create_apns_config({
'APNS_CERTIFICATE': '<path/to/certificate.pem>'
})
client = APNSClient(config)
# Send to single device.
client.send(token, alert, **options)
# Send to multiple devices.
client.send_bulk(tokens, alert, **options)
# Get expired tokens.
expired = client.get_expired_tokens()
GCM
from pushjack import GCMClient, create_gcm_config
config = create_gcm_config({
'GCM_API_KEY': '<api key>'
})
client = GCMClient(config)
# Send to single device.
client.send(token, alert, **options)
# Send to multiple devices.
client.send_bulk(tokens, alert, **options)
Config
The config object for configuring a client is expected to be a dict or subclass of dict:
gcm_config = {
'GCM_API_KEY': '<api key>',
'GCM_URL': 'https://android.googleapis.com/gcm/send',
'GCM_MAX_RECIPIENTS': 1000
}
apns_config = {
'APNS_CERTIFICATE': '<path/to/certificate.pem>',
'APNS_HOST': 'gateway.push.apple.com',
'APNS_PORT': 2195,
'APNS_FEEDBACK_HOST': 'feedback.push.apple.com',
'APNS_FEEDBACK_PORT': 2196,
'APNS_ERROR_TIMEOUT': 0.5,
'APNS_DEFAULT_EXPIRATION_OFFSET': 60 * 60 * 24 * 30
'APNS_MAX_NOTIFICATION_SIZE': 2048
}
For a class based approached, configuration classes are provided for subclassing which can be passed to each client class. By default, both GCMConfig, APNSConfig, and APNSSandboxConfig will set default values for the settings that shouldn’t change. You will need to set GCM_API_KEY or APNS_CERTIFICATE appropriately though:
from pushjack import GCMClient, GCMConfig, APNSConfig, APNSSandboxConfig
class MyGCMConfig(GCMConfig):
GCM_API_KEY = '<api key>'
class MyAPNSConfig(APNSConfig):
APNS_CERTIFICATE = '<path/to/certificate.pem>'
class MyAPNSSandboxConfig(APNSConfig):
APNS_CERTIFICATE = '<path/to/certificate.pem>'
client = GCMClient(MyGCMConfig)
NOTE: You can only pass in a class to the client initializer if it is a subclass of one of the provided *Config classes.
For more details, please see the full documentation at http://pushjack.readthedocs.org.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for pushjack-0.1.0-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0dcd8faf6dc6b9276103af8f069d0fa9f7df52994683d243b2c9a137612741b9 |
|
MD5 | d41a2ca2cf7a40ff1a3663483f2eb784 |
|
BLAKE2b-256 | 1c2161d8b7cb0819e1a2d12ae8cdd823614230e028721a92f064d27cc6578377 |