From 223f7cc0b49d686aaf88323d12af60e37ce9913f Mon Sep 17 00:00:00 2001 From: Juan Leyva Date: Sat, 31 Oct 2020 13:07:30 +0100 Subject: [PATCH] MDL-70081 airnotifier: Add missing device type in token registration --- message/output/airnotifier/classes/manager.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/message/output/airnotifier/classes/manager.php b/message/output/airnotifier/classes/manager.php index 1654857e985..f75ee8577cd 100644 --- a/message/output/airnotifier/classes/manager.php +++ b/message/output/airnotifier/classes/manager.php @@ -92,7 +92,7 @@ class message_airnotifier_manager { array('userdeviceid' => $device->id))) { // We have to create the device token in airnotifier. - if (! $this->create_token($device->pushid)) { + if (! $this->create_token($device->pushid, $device->platform)) { continue; } @@ -149,9 +149,10 @@ class message_airnotifier_manager { /** * Create a device token in the Airnotifier instance * @param string $token The token to be created + * @param string $deviceplatform The device platform (Android, iOS, iOS-fcm, etc...) * @return bool True if all was right */ - private function create_token($token) { + private function create_token($token, $deviceplatform = '') { global $CFG; if (!$this->is_system_configured()) { @@ -165,7 +166,10 @@ class message_airnotifier_manager { 'X-AN-APP-KEY: ' . $CFG->airnotifieraccesskey); $curl = new curl; $curl->setHeader($header); - $params = array(); + $params = []; + if (!empty($deviceplatform)) { + $params["device"] = $deviceplatform; + } $resp = $curl->post($serverurl, $params); if ($token = json_decode($resp, true)) {