|
1 | 1 | .. image:: https://travis-ci.org/pusher/push-notifications-python.svg?branch=master
|
2 | 2 | :target: https://travis-ci.org/pusher/push-notifications-python
|
| 3 | +.. image:: https://codecov.io/gh/pusher/push-notifications-python/branch/master/graph/badge.svg |
| 4 | + :target: https://codecov.io/gh/pusher/push-notifications-python |
3 | 5 |
|
4 | 6 | Pusher Beams Python server SDK
|
5 | 7 | ==============================
|
@@ -35,16 +37,54 @@ Use your instance id and secret (you can get these from the
|
35 | 37 | secret_key='YOUR_SECRET_KEY_HERE',
|
36 | 38 | )
|
37 | 39 |
|
38 |
| -Publishing a Notification |
39 |
| -~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 40 | +Publishing to Device Interests |
| 41 | +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
40 | 42 |
|
41 |
| -Once you have created your Beams PushNotifications instance you can publish a push notification to your registered & subscribed devices: |
| 43 | +You can broadcast notifications to groups of subscribed devices using `Device Interests <https://docs.pusher.com/beams/concepts/device-interests>`__: |
42 | 44 |
|
43 | 45 | .. code::
|
44 | 46 |
|
45 |
| - response = pn_client.publish( |
| 47 | + response = pn_client.publish_to_interests( |
46 | 48 | interests=['hello'],
|
47 |
| - publish_body={'apns': {'aps': {'alert': 'Hello!'}}, 'fcm': {'notification': {'title': 'Hello', 'body': 'Hello, World!'}}} |
| 49 | + publish_body={ |
| 50 | + 'apns': { |
| 51 | + 'aps': { |
| 52 | + 'alert': 'Hello!' |
| 53 | + } |
| 54 | + }, |
| 55 | + 'fcm': { |
| 56 | + 'notification': { |
| 57 | + 'title': 'Hello', |
| 58 | + 'body': 'Hello, World!' |
| 59 | + } |
| 60 | + } |
| 61 | + } |
| 62 | + ) |
| 63 | +
|
| 64 | + print(response['publishId']) |
| 65 | +
|
| 66 | +Publishing to Authenticated Users |
| 67 | +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 68 | + |
| 69 | +Securely send notifications to individual users of your application using `Authenticated Users <https://docs.pusher.com/beams/concepts/authenticated-users>`__: |
| 70 | + |
| 71 | +.. code:: |
| 72 | +
|
| 73 | + response = pn_client.publish_to_users( |
| 74 | + user_ids=['user-0001'], |
| 75 | + publish_body={ |
| 76 | + 'apns': { |
| 77 | + 'aps': { |
| 78 | + 'alert': 'Hello!' |
| 79 | + } |
| 80 | + }, |
| 81 | + 'fcm': { |
| 82 | + 'notification': { |
| 83 | + 'title': 'Hello', |
| 84 | + 'body': 'Hello, World!' |
| 85 | + } |
| 86 | + } |
| 87 | + } |
48 | 88 | )
|
49 | 89 |
|
50 | 90 | print(response['publishId'])
|
0 commit comments