mirror of
https://github.com/moodle/moodle.git
synced 2025-04-28 11:55:58 +02:00
MDL-78072 airnotifier: Apply payload size optimisation to all push
Backport of MDL-77893. Co-authored by: Andrew Lyons <andrew@nicols.co.uk>
This commit is contained in:
parent
1af4ace4d6
commit
d838917d28
@ -133,6 +133,15 @@ class message_output_airnotifier extends message_output {
|
|||||||
|
|
||||||
$extra->encrypted = $encryptnotifications;
|
$extra->encrypted = $encryptnotifications;
|
||||||
$extra = $this->encrypt_payload($extra, $devicetoken);
|
$extra = $this->encrypt_payload($extra, $devicetoken);
|
||||||
|
|
||||||
|
// We use Firebase to deliver all Push Notifications, and for all device types.
|
||||||
|
// Firebase has a 4KB payload limit.
|
||||||
|
// https://firebase.google.com/docs/cloud-messaging/concept-options#notifications_and_data_messages
|
||||||
|
// If the message is over that limit we remove unneeded fields and replace the title with a simple message.
|
||||||
|
if (\core_text::strlen(json_encode($extra), '8bit') > 4000) {
|
||||||
|
$extra->smallmessage = get_string('view_notification', 'message_airnotifier');
|
||||||
|
}
|
||||||
|
|
||||||
$params = array(
|
$params = array(
|
||||||
'device' => $devicetoken->platform,
|
'device' => $devicetoken->platform,
|
||||||
'token' => $devicetoken->pushid,
|
'token' => $devicetoken->pushid,
|
||||||
@ -203,14 +212,6 @@ class message_output_airnotifier extends message_output {
|
|||||||
unset($payload->attachment);
|
unset($payload->attachment);
|
||||||
unset($payload->attachname);
|
unset($payload->attachname);
|
||||||
|
|
||||||
// We use Firebase to deliver all Push Notifications, and for all device types.
|
|
||||||
// Firebase has a 4KB payload limit.
|
|
||||||
// https://firebase.google.com/docs/cloud-messaging/concept-options#notifications_and_data_messages
|
|
||||||
// If the message is over that limit we remove unneeded fields and replace the title with a simple message.
|
|
||||||
if (\core_text::strlen(json_encode($payload), '8bit') > 4000) {
|
|
||||||
$payload->smallmessage = get_string('view_notification', 'message_airnotifier');
|
|
||||||
}
|
|
||||||
|
|
||||||
return $payload;
|
return $payload;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user