Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
class AuthenticationError(FCMError):
"""
API key not found or there was an error authenticating the sender
"""
pass
class FCMNotRegisteredError(FCMError):
"""
push token is not registered
https://firebase.google.com/docs/reference/fcm/rest/v1/ErrorCode
"""
pass
class FCMServerError(FCMError):
"""
Internal server error or timeout error on Firebase cloud messaging server
"""
pass
class InvalidDataError(FCMError):
"""
Invalid input
"""
pass
class InternalPackageError(FCMError):
"""
JSON parsing error, please create a new github issue describing what you're doing
class FCMError(Exception):
"""
PyFCM Error
"""
pass
class AuthenticationError(FCMError):
"""
API key not found or there was an error authenticating the sender
"""
pass
class FCMNotRegisteredError(FCMError):
"""
push token is not registered
https://firebase.google.com/docs/reference/fcm/rest/v1/ErrorCode
"""
pass
class FCMServerError(FCMError):
"""
class FCMError(Exception):
"""
PyFCM Error
"""
pass
class AuthenticationError(FCMError):
"""
API key not found or there was an error authenticating the sender
"""
pass
class FCMNotRegisteredError(FCMError):
"""
push token is not registered
https://firebase.google.com/docs/reference/fcm/rest/v1/ErrorCode
"""
pass
class FCMServerError(FCMError):
"""
Internal server error or timeout error on Firebase cloud messaging server
"""
pass
class InvalidDataError(FCMError):
"""
InvalidDataError: data sent to server was incorrectly formatted
FCMError: an error occured on the server
"""
url = 'https://iid.googleapis.com/iid/v1:batchAdd'
payload = {
'to': '/topics/' + topic_name,
'registration_tokens': registration_ids,
}
response = self.requests_session.post(url, json=payload)
if response.status_code == 200:
return True
elif response.status_code == 400:
error = response.json()
raise InvalidDataError(error['error'])
else:
raise FCMError()
class FCMNotRegisteredError(FCMError):
"""
push token is not registered
https://firebase.google.com/docs/reference/fcm/rest/v1/ErrorCode
"""
pass
class FCMServerError(FCMError):
"""
Internal server error or timeout error on Firebase cloud messaging server
"""
pass
class InvalidDataError(FCMError):
"""
Invalid input
"""
pass
class InternalPackageError(FCMError):
"""
JSON parsing error, please create a new github issue describing what you're doing
"""
pass
class RetryAfterException(Exception):
"""
Retry-After must be handled by external logic.
class FCMServerError(FCMError):
"""
Internal server error or timeout error on Firebase cloud messaging server
"""
pass
class InvalidDataError(FCMError):
"""
Invalid input
"""
pass
class InternalPackageError(FCMError):
"""
JSON parsing error, please create a new github issue describing what you're doing
"""
pass
class RetryAfterException(Exception):
"""
Retry-After must be handled by external logic.
"""
def __init__(self, delay):
self.delay = delay
InvalidDataError: data sent to server was incorrectly formatted
FCMError: an error occured on the server
"""
url = "https://iid.googleapis.com/iid/v1:batchRemove"
payload = {
'to': '/topics/' + topic_name,
'registration_tokens': registration_ids,
}
response = self.requests_session.post(url, json=payload)
if response.status_code == 200:
return True
elif response.status_code == 400:
error = response.json()
raise InvalidDataError(error['error'])
else:
raise FCMError()