diff --git a/CHANGELOG.md b/CHANGELOG.md index a8ca4702d2..b130e307f8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - When the `DANGEROUS_WEBHOOKS_ENABLED` environment variable is set to true, it's possible now to create Outgoing Webhooks using URLs without a top-level domain ([1266](https://github.com/grafana/oncall/pull/1266)) - Updated wording when creating an integration ([1572](https://github.com/grafana/oncall/pull/1572)) +- Set FCM iOS/Android "message priority" to "high priority" for mobile app push notifications ([1612](https://github.com/grafana/oncall/pull/1612)) ## v1.2.1 (2023-03-23) diff --git a/engine/apps/mobile_app/tasks.py b/engine/apps/mobile_app/tasks.py index dec51193d6..24658ea429 100644 --- a/engine/apps/mobile_app/tasks.py +++ b/engine/apps/mobile_app/tasks.py @@ -6,7 +6,7 @@ from django.conf import settings from fcm_django.models import FCMDevice from firebase_admin.exceptions import FirebaseError -from firebase_admin.messaging import APNSConfig, APNSPayload, Aps, ApsAlert, CriticalSound, Message +from firebase_admin.messaging import AndroidConfig, APNSConfig, APNSPayload, Aps, ApsAlert, CriticalSound, Message from requests import HTTPError from rest_framework import status @@ -185,6 +185,21 @@ def _get_fcm_message(alert_group, user, registration_id, critical): mobile_app_user_settings.important_notification_override_dnd ), }, + android=AndroidConfig( + # from the docs + # https://firebase.google.com/docs/cloud-messaging/concept-options#setting-the-priority-of-a-message + # + # Normal priority. + # Normal priority messages are delivered immediately when the app is in the foreground. + # For backgrounded apps, delivery may be delayed. For less time-sensitive messages, such as notifications + # of new email, keeping your UI in sync, or syncing app data in the background, choose normal delivery + # priority. + # + # High priority. + # FCM attempts to deliver high priority messages immediately even if the device is in Doze mode. + # High priority messages are for time-sensitive, user visible content. + priority="high", + ), apns=APNSConfig( payload=APNSPayload( aps=Aps( @@ -201,6 +216,11 @@ def _get_fcm_message(alert_group, user, registration_id, critical): "interruption-level": "critical" if critical else "time-sensitive", }, ), + headers={ + # From the docs + # https://firebase.google.com/docs/cloud-messaging/concept-options#setting-the-priority-of-a-message + "apns-priority": "10", + }, ), ), )