Skip to content

Commit 047b195

Browse files
Merge pull request #15 from pusher/add-users-support
Add users support
2 parents ea0b306 + cf1cd2a commit 047b195

File tree

8 files changed

+1369
-410
lines changed

8 files changed

+1369
-410
lines changed

.travis.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@ python:
55
install:
66
- pip install -Ur requirements.txt
77
- pip install -Ur dev_requirements.txt
8+
- pip install codecov
89
script:
910
- python -m pylint ./pusher_push_notifications/*.py
10-
- python -m nose -s
11+
- python -m nose -s --with-coverage
1112
- python setup.py checkdocs
13+
after_success:
14+
- codecov

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
55
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
66

77
## [Unreleased]
8+
### Added
9+
- Support for "Authenticated Users" feature: `publish_to_users`, `generate_token` and `delete_user`
10+
11+
### Changed
12+
- `publish` renamed to `publish_to_interests` (`publish` method deprecated).
813

914
## [1.0.3] - 2019-01-16
1015
### Fixed

README.rst

Lines changed: 45 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
.. image:: https://travis-ci.org/pusher/push-notifications-python.svg?branch=master
22
: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
35

46
Pusher Beams Python server SDK
57
==============================
@@ -35,16 +37,54 @@ Use your instance id and secret (you can get these from the
3537
secret_key='YOUR_SECRET_KEY_HERE',
3638
)
3739
38-
Publishing a Notification
39-
~~~~~~~~~~~~~~~~~~~~~~~~~
40+
Publishing to Device Interests
41+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4042

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>`__:
4244

4345
.. code::
4446
45-
response = pn_client.publish(
47+
response = pn_client.publish_to_interests(
4648
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+
}
4888
)
4989
5090
print(response['publishId'])

0 commit comments

Comments
 (0)