send uuid with results push
This commit is contained in:
@@ -52,10 +52,24 @@ def create_apns_client():
|
|||||||
)
|
)
|
||||||
return APNsClient(credentials=token_credentials, use_sandbox=False)
|
return APNsClient(credentials=token_credentials, use_sandbox=False)
|
||||||
|
|
||||||
def send_notification(device_token, title, subtitle, text):
|
def send_notification(device_token, title, subtitle, text, uuid=None):
|
||||||
try:
|
try:
|
||||||
apns_client = create_apns_client()
|
apns_client = create_apns_client()
|
||||||
payload = Payload(alert=title, sound="default", badge=1, custom={"subtitle": subtitle, "text": text})
|
custom_data = {
|
||||||
|
"subtitle": subtitle,
|
||||||
|
"text": text
|
||||||
|
}
|
||||||
|
if uuid:
|
||||||
|
custom_data["uuid"] = uuid
|
||||||
|
|
||||||
|
payload = Payload(
|
||||||
|
alert={"title": title, "body": text},
|
||||||
|
sound="default",
|
||||||
|
badge=1,
|
||||||
|
category="RACE_RESULT",
|
||||||
|
custom=custom_data
|
||||||
|
)
|
||||||
|
|
||||||
apns_client.send_notification(device_token, payload, topic)
|
apns_client.send_notification(device_token, payload, topic)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"Fehler beim Senden der Benachrichtigung: {e}")
|
print(f"Fehler beim Senden der Benachrichtigung: {e}")
|
||||||
@@ -172,7 +186,13 @@ def custom_notify():
|
|||||||
|
|
||||||
device_tokens = DeviceToken.query.all()
|
device_tokens = DeviceToken.query.all()
|
||||||
for token in device_tokens:
|
for token in device_tokens:
|
||||||
send_notification(token.device_token, title, subtitle, text)
|
send_notification(
|
||||||
|
token.device_token,
|
||||||
|
title=title,
|
||||||
|
subtitle=subtitle,
|
||||||
|
text=text,
|
||||||
|
uuid=result['uuid']
|
||||||
|
)
|
||||||
|
|
||||||
return jsonify({"message": "Benachrichtigungen gesendet"}), 200
|
return jsonify({"message": "Benachrichtigungen gesendet"}), 200
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|||||||
Reference in New Issue
Block a user