From 924ffdbcdb8b4c2a645c5eab452a1bbbea611bfc Mon Sep 17 00:00:00 2001 From: Aditya Varma Date: Mon, 11 Mar 2019 20:04:02 +0530 Subject: [PATCH] Documentation for batching and tokens authenticate Update examples for batching support and token based authentication. --- README.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/README.md b/README.md index be8ddb4..a23deff 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,21 @@ payload = Payload(alert="Hello World!", sound="default", badge=1) topic = 'com.example.App' client = APNsClient('key.pem', use_sandbox=False, use_alternative_port=False) client.send_notification(token_hex, payload, topic) + +# To send multiple notifications in a batch +Notification = collections.namedtuple('Notification', ['token', 'payload']) +notifications = [Notification(payload=payload, token=token_hex)] +client.send_notification_batch(notifications=notifications, topic=topic) + +# To use token based authentication +from apsn2.credentials import TokenCredentials + +auth_key_path = 'path/to/auth_key' +auth_key_id = 'app_auth_key_id' +team_id = 'app_team_id' +token_credentials = TokensCredentials(auth_key_path=auth_key_path, auth_key_id=auth_key_id, team_id=team_id) +client = APNsClient(credentials=token_credentials, use_sanbox=False) +client.send_notification_batch(notifications=notifications, topic=topic) ``` ## Further Info