Skip to content

Commit

Permalink
Merge branch 'MDL-70081-master' of git://github.com/jleyva/moodle int…
Browse files Browse the repository at this point in the history
…o master
  • Loading branch information
stronk7 committed Nov 3, 2020
2 parents a81f648 + 4bc5333 commit cb16353
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions message/output/airnotifier/classes/manager.php
Expand Up @@ -92,7 +92,7 @@ public function get_user_devices($appname, $userid = null) {
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;
}

Expand Down Expand Up @@ -149,9 +149,10 @@ public function request_accesskey() {
/**
* 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()) {
Expand All @@ -165,7 +166,10 @@ private function create_token($token) {
'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)) {
Expand Down

0 comments on commit cb16353

Please sign in to comment.