-
-
Notifications
You must be signed in to change notification settings - Fork 618
Multiple Application Support
Multiple Application Support requires Django Push Notifications 1.5.
Technically, Django Push Notifications has supported multiple applications for a while but was limited to a single application for each platform. This document will show you how to configure Django Push Notifications to allow multiple applications for each platform.
To enable Multiple Application Support, set: PUSH_NOTIFICATIONS_SETTINGS["CONFIG"] = "push_notifications.conf.AppConfig"
With the AppConfig enabled, all platform defaults defined on PUSH_NOTIFICATIONS_SETTINGS
will be ignored.
Please note:
- When using AppConfig, the DEBUG setting does not effect the configured APNS host settings for an application.
- All settings are checked at startup. Any invalid settings (including file io errors related to APNS certificates), will raise an ImproperlyConfigured error.
- An empty
PUSH_NOTIFICATIONS_SETTINGS.APPLICATIONS
collection is acceptable.
Applications must be added to the PUSH_NOTIFICATIONS_SETTINGS["APPLICATIONS"]
dictionary.
The dictionary key is the APPLICATION_ID
. It may contain alphanumeric characters and underscores. Keep it short but meaningful.
The value is a dictionary that must contain the key PLATFORM
. PLATFORM must be one of APNS, FCM, GCM, or WNS. PLATFORM
determines which additional attributes are required as well as setting reasonable defaults for any optional settings.
PUSH_NOTIFICATIONS_SETTINGS = {
# Load and process all PUSH_NOTIFICATIONS_SETTINGS using the AppConfig manager.
"CONFIG": "push_notifications.conf.AppConfig",
# collection of all defined applications
"APPLICATIONS": {
"<APPLICATION_ID>": {
# PLATFORM (required) determines what additional settings are required.
"PLATFORM": "<PLATFORM>",
},
}
}
APNS
-
CERTIFICATE
: Absolute path to your APNS certificate file. Certificates with passphrases are not supported. Required. -
HOST
: The hostname used for the APNS sockets. Optional, defaults togateway.push.apple.com
. -
PORT
: The port used along with APNS_HOST. Optional, defaults to 2195. -
ERROR_TIMEOUT
: The timeout on APNS sockets. Optional. -
TOPIC
: The topic of the remote notification, which is typically the bundle ID for your app. If you omit this header and your APNs certificate does not specify multiple topics, the APNs server uses the certificate’s Subject as the default topic. -
USE_SANDBOX
: Use 'api.development.push.apple.com', instead of default host 'api.push.apple.com'. Optional, Default to False.
FCM
-
API_KEY
: Your API key for Firebase Cloud Messaging. -
POST_URL
: The full url that FCM notifications will be POSTed to. Defaults to https://fcm.googleapis.com/fcm/send. -
MAX_RECIPIENTS
: The maximum amount of recipients that can be contained per bulk message. If theregistration_ids
list is larger than that number, multiple bulk messages will be sent. Defaults to 1000 (the maximum amount supported by FCM). -
ERROR_TIMEOUT
: The timeout on GCM POSTs.
GCM
-
API_KEY
: Your API key for Google Cloud Messaging. -
POST_URL
: The full url that GCM notifications will be POSTed to. Defaults to https://android.googleapis.com/gcm/send. -
MAX_RECIPIENTS
: The maximum amount of recipients that can be contained per bulk message. If theregistration_ids
list is larger than that number, multiple bulk messages will be sent. Defaults to 1000 (the maximum amount supported by GCM). -
ERROR_TIMEOUT
: The timeout on GCM POSTs.
WNS
-
PACKAGE_SECURITY_KEY
: TODO -
SECRET_KEY
: TODO
This example mirrors the original settings behavior. One application per platform.
PUSH_NOTIFICATIONS_SETTINGS = {
# Load and process all PUSH_NOTIFICATIONS_SETTINGS using the AppConfig manager.
"CONFIG": "push_notifications.conf.AppConfig",
# collection of all defined applications
"APPLICATIONS": {
"my_fcm_app": {
# PLATFORM (required) determines what additional settings are required.
"PLATFORM": "FCM",
# required FCM setting
"API_KEY": "[your api key]",
},
"my_ios_app": {
# PLATFORM (required) determines what additional settings are required.
"PLATFORM": "APNS",
# required APNS setting
"CERTIFICATE": "/path/to/your/certificate.pem",
},
"my_wns_app": {
# PLATFORM (required) determines what additional settings are required.
"PLATFORM": "WNS",
# required WNS settings
"PACKAGE_SECURITY_ID": "[your package security id, e.g: 'ms-app://e-3-4-6234...']",
"SECRET_KEY": "[your app secret key, e.g.: 'KDiejnLKDUWodsjmewuSZkk']",
},
}
}
In this example, the developer maintains multiple applications for iOS and Android.
There are 3 iOS applications: iPhone, iPad, as well as the legacy version of the
application that is being phased out. There are two applications for Android. The
fcm_chat
app is for the US market and fcm_em
is for emerging markets.
PUSH_NOTIFICATIONS_SETTINGS = {
# Load and process all PUSH_NOTIFICATIONS_SETTINGS using the AppConfig manager.
"CONFIG": "push_notifications.conf.AppConfig",
# collection of all defined applications
"APPLICATIONS": {
"fcm_chat": {
# PLATFORM (required) determines what additional settings are required.
"PLATFORM": "FCM",
# required FCM setting
"API_KEY": "[your api key]",
},
"fcm_em": {
# PLATFORM (required) determines what additional settings are required.
"PLATFORM": "FCM",
# required FCM setting
"API_KEY": "[your api key]",
},
"ios_iphone_old": {
# PLATFORM (required) determines what additional settings are required.
"PLATFORM": "APNS",
# required APNS setting
"CERTIFICATE": "/path/to/your/certificate.pem",
},
"ios_iphone": {
# PLATFORM (required) determines what additional settings are required.
"PLATFORM": "APNS",
# required APNS setting
"CERTIFICATE": "/path/to/your/certificate.pem",
},
"ios_ipad": {
# PLATFORM (required) determines what additional settings are required.
"PLATFORM": "APNS",
# required APNS setting
"CERTIFICATE": "/path/to/your/certificate.pem",
}
}
}