You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Note: If you are planning on running your project with `DEBUG=True`, then make sure you have set the
50
-
*development* certificate as your `APNS_CERTIFICATE`. Otherwise the app will not be able to connect to the correct host.
50
+
.. note::
51
+
If you are planning on running your project with ``DEBUG=True``, then make sure you have set the
52
+
*development* certificate as your ``APNS_CERTIFICATE``. Otherwise the app will not be able to connect to the correct host. See settings_ for details.
51
53
52
-
You can learn more about APNS certificates here: https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Chapters/ProvisioningDevelopment.html
54
+
You can learn more about APNS certificates `here<https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Chapters/ProvisioningDevelopment.html>`_.
53
55
54
-
Native Django migrations are in use. `manage.py migrate` will install and migrate all models.
56
+
Native Django migrations are in use. ``manage.py migrate`` will install and migrate all models.
55
57
58
+
.. _settings:
56
59
57
60
Settings list
58
61
-------------
59
-
All settings are contained in a PUSH_NOTIFICATIONS_SETTINGS dict.
62
+
All settings are contained in a ``PUSH_NOTIFICATIONS_SETTINGS`` dict.
60
63
61
-
In order to use GCM, you are required to include GCM_API_KEY.
62
-
For APNS, you are required to include APNS_CERTIFICATE.
64
+
In order to use GCM, you are required to include ``GCM_API_KEY``.
65
+
For APNS, you are required to include ``APNS_CERTIFICATE``.
63
66
64
-
- APNS_CERTIFICATE: Absolute path to your APNS certificate file. Certificates with passphrases are not supported.
65
-
- GCM_API_KEY: Your API key for GCM.
66
-
- APNS_HOST: The hostname used for the APNS sockets. When DEBUG=True, this defaults to gateway.sandbox.push.apple.com. When DEBUG=False, this defaults to gateway.push.apple.com.
67
-
- APNS_PORT: The port used along with APNS_HOST. Defaults to 2195.
68
-
- GCM_POST_URL: The full url that GCM notifications will be POSTed to. Defaults to https://android.googleapis.com/gcm/send.
69
-
- GCM_MAX_RECIPIENTS: The maximum amount of recipients that can be contained per bulk message. If the registration_ids list is larger than that number, multiple bulk messages will be sent. Defaults to 1000 (the maximum amount supported by GCM).
67
+
- ``APNS_CERTIFICATE``: Absolute path to your APNS certificate file. Certificates with passphrases are not supported.
68
+
- ``GCM_API_KEY``: Your API key for GCM.
69
+
- ``APNS_HOST``: The hostname used for the APNS sockets.
70
+
- When ``DEBUG=True``, this defaults to ``gateway.sandbox.push.apple.com``.
71
+
- When ``DEBUG=False``, this defaults to ``gateway.push.apple.com``.
72
+
- ``APNS_PORT``: The port used along with APNS_HOST. Defaults to 2195.
73
+
- ``GCM_POST_URL``: The full url that GCM notifications will be POSTed to. Defaults to https://android.googleapis.com/gcm/send.
74
+
- ``GCM_MAX_RECIPIENTS``: The maximum amount of recipients that can be contained per bulk message. If the ``registration_ids`` list is larger than that number, multiple bulk messages will be sent. Defaults to 1000 (the maximum amount supported by GCM).
70
75
71
76
Sending messages
72
77
----------------
73
78
GCM and APNS services have slightly different semantics. The app tries to offer a common interface for both when using the models.
74
79
75
-
::
80
+
.. code-block:: python
76
81
77
82
from push_notifications.models import APNSDevice, GCMDevice
78
83
@@ -92,14 +97,14 @@ GCM and APNS services have slightly different semantics. The app tries to offer
92
97
device.send_message(None, badge=5) # No alerts but with badge.
93
98
device.send_message(None, badge=1, extra={"foo": "bar"}) # Silent message with badge and added custom data.
94
99
95
-
Note that APNS does not support sending payloads that exceed 2048 bytes (increased from 256 in 2014).
96
-
The message is only one part of the payload, if
97
-
once constructed the payload exceeds the maximum size, an APNSDataOverflow exception will be raised before anything is sent.
98
-
100
+
.. note::
101
+
APNS does not support sending payloads that exceed 2048 bytes (increased from 256 in 2014).
102
+
The message is only one part of the payload, if
103
+
once constructed the payload exceeds the maximum size, an ``APNSDataOverflow`` exception will be raised before anything is sent.
99
104
100
105
Sending messages in bulk
101
106
------------------------
102
-
::
107
+
.. code-block:: python
103
108
104
109
from push_notifications.models import APNSDevice, GCMDevice
105
110
@@ -111,29 +116,28 @@ bulk notifications instead of single ones.
111
116
112
117
Administration
113
118
--------------
119
+
114
120
APNS devices which are not receiving push notifications can be set to inactive by two methods. The web admin interface for
115
-
APNS devices has a "prune devices" option. Any selected devices which are not receiving notifications will be set to inactive(*).
116
-
There is also a management command to prune all devices failing to receive notifications::
121
+
APNS devices has a "prune devices" option. Any selected devices which are not receiving notifications will be set to inactive [1]_.
122
+
There is also a management command to prune all devices failing to receive notifications:
123
+
124
+
.. code-block:: shell
117
125
118
-
python manage.py prune_devices
126
+
$ python manage.py prune_devices
119
127
120
128
This removes all devices which are not receiving notifications.
121
129
122
130
For more information, please refer to the APNS feedback service_.
(*)Any devices which are not selected, but are not receiving notifications will not be deactivated on a subsequent call to "prune devices" unless another
127
-
attempt to send a message to the device fails after the call to the feedback service.
128
-
129
134
Exceptions
130
135
----------
131
136
132
-
- NotificationError(Exception): Base exception for all notification-related errors.
133
-
- gcm.GCMError(NotificationError): An error was returned by GCM. This is never raised when using bulk notifications.
134
-
- apns.APNSError(NotificationError): Something went wrong upon sending APNS notifications.
135
-
- apns.APNSDataOverflow(APNSError): The APNS payload exceeds its maximum size and cannot be sent.
136
-
137
+
- ``NotificationError(Exception)``: Base exception for all notification-related errors.
138
+
- ``gcm.GCMError(NotificationError)``: An error was returned by GCM. This is never raised when using bulk notifications.
139
+
- ``apns.APNSError(NotificationError)``: Something went wrong upon sending APNS notifications.
140
+
- ``apns.APNSDataOverflow(APNSError)``: The APNS payload exceeds its maximum size and cannot be sent.
137
141
138
142
Tastypie support
139
143
----------------
@@ -142,19 +146,20 @@ The app includes tastypie-compatible resources in push_notifications.api. These
142
146
for more involved APIs.
143
147
The following resources are available:
144
148
145
-
- APNSDeviceResource
146
-
- GCMDeviceResource
147
-
- APNSDeviceAuthenticatedResource
148
-
- GCMDeviceAuthenticatedResource
149
+
- ``APNSDeviceResource``
150
+
- ``GCMDeviceResource``
151
+
- ``APNSDeviceAuthenticatedResource``
152
+
- ``GCMDeviceAuthenticatedResource``
149
153
150
154
The base device resources will not ask for authentication, while the authenticated ones will link the logged in user to
151
155
the device they register.
152
-
Subclassing the authenticated resources in order to add a SameUserAuthentication and a user ForeignKey is recommended.
153
-
154
-
When registered, the APIs will show up at <api_root>/device/apns and <api_root>/device/gcm, respectively.
156
+
Subclassing the authenticated resources in order to add a ``SameUserAuthentication`` and a user ``ForeignKey`` is recommended.
155
157
158
+
When registered, the APIs will show up at ``<api_root>/device/apns`` and ``<api_root>/device/gcm``, respectively.
156
159
157
160
Python 3 support
158
161
----------------
159
162
160
-
django-push-notifications is fully compatible with Python 3.
163
+
``django-push-notifications`` is fully compatible with Python 3.
164
+
165
+
.. [1] Any devices which are not selected, but are not receiving notifications will not be deactivated on a subsequent call to "prune devices" unless another attempt to send a message to the device fails after the call to the feedback service.
0 commit comments