Use only one JWT token per connection (#80)

This fixes #76 where you a TooManyProviderTokenUpdates if you send
notifications to multiple topics over one connection.

As Apple states here https://developer.apple.com/documentation/usernotifications/setting_up_a_remote_notification_server/establishing_a_token-based_connection_to_apns#2943374
one connection shall use only one single JWT token which should be
refreshed no more than once every 20 minutes and no less than once every
60 minutes.
This commit is contained in:
shintonik
2019-05-23 02:01:31 +03:00
committed by Sergey Petrov
parent 95c19c64d7
commit fbcf36f955
2 changed files with 5 additions and 13 deletions
-7
View File
@@ -39,13 +39,6 @@ class TokenCredentialsTestCase(TestCase):
self.expiring_header = self.expiring_creds.get_authorization_header(
self.topics[0])
def test_create_multiple_topics(self):
h1 = self.normal_creds.get_authorization_header(self.topics[0])
self.assertEqual(len(self.normal_creds.get_tokens()), 1)
h2 = self.normal_creds.get_authorization_header(self.topics[1])
self.assertNotEqual(h1, h2)
self.assertEqual(len(self.normal_creds.get_tokens()), 2)
def test_token_expiration(self):
# As long as the token lifetime hasn't elapsed, this should work. To
# be really careful, we should check how much time has elapsed to