diff --git a/admin/tool/mobile/classes/api.php b/admin/tool/mobile/classes/api.php index c7f537d6e42df..a9dc790dbff84 100644 --- a/admin/tool/mobile/classes/api.php +++ b/admin/tool/mobile/classes/api.php @@ -61,6 +61,10 @@ class api { const QR_CODE_URL = 1; /** @var int QR code type login value */ const QR_CODE_LOGIN = 2; + /** @var string Default Android app id */ + const DEFAULT_ANDROID_APP_ID = 'com.moodle.moodlemobile'; + /** @var string Default iOS app id */ + const DEFAULT_IOS_APP_ID = '633359593'; /** * Returns a list of Moodle plugins supporting the mobile app. @@ -689,14 +693,17 @@ public static function get_subscription_information() : ?array { $credentials[] = ['type' => 'siteid', 'value' => $CFG->siteidentifier]; } // Generate a hash key for validating that the request is coming from this site via WS. - $sitesubscriptionkey = json_encode(['validuntil' => time() + 10 * MINSECS, 'key' => complex_random_string(32)]); + $key = complex_random_string(32); + $sitesubscriptionkey = json_encode(['validuntil' => time() + 10 * MINSECS, 'key' => $key]); set_config('sitesubscriptionkey', $sitesubscriptionkey, 'tool_mobile'); - $credentials[] = ['type' => 'sitesubscriptionkey', 'value' => $sitesubscriptionkey]; + $credentials[] = ['type' => 'sitesubscriptionkey', 'value' => $key]; // Parameters for the WebService returning site information. + $androidappid = empty($mobilesettings->androidappid) ? static::DEFAULT_ANDROID_APP_ID : $mobilesettings->androidappid; + $iosappid = empty($mobilesettings->iosappid) ? static::DEFAULT_IOS_APP_ID : $mobilesettings->iosappid; $fnparams = (object) [ 'siteurl' => $CFG->wwwroot, - 'appids' => [$mobilesettings->androidappid, $mobilesettings->iosappid], + 'appids' => [$androidappid, $iosappid], 'credentials' => $credentials, ]; // Prepare the arguments for a request to the AJAX nologin endpoint. diff --git a/admin/tool/mobile/lang/en/tool_mobile.php b/admin/tool/mobile/lang/en/tool_mobile.php index ae42c54f00b1d..3f270eab9b3e3 100644 --- a/admin/tool/mobile/lang/en/tool_mobile.php +++ b/admin/tool/mobile/lang/en/tool_mobile.php @@ -98,7 +98,7 @@ $string['notificationsactivedevices'] = 'Active devices'; $string['notificationsignorednotifications'] = 'Notifications not sent'; $string['notificationslimitreached'] = 'The monthly active user devices limit has been exceeded. Notifications for some users will not be sent. It is recommended that you upgrade your app plan in the Moodle Apps Portal.'; -$string['notificationsmissingwarning'] = 'Moodle app notification statistics could not be retrieved. This is most likely because mobile notifications are not yet enabled on the site.'; +$string['notificationsmissingwarning'] = 'Moodle app notification statistics could not be retrieved. This is most likely because mobile notifications are not yet enabled on the site. You can enable them in Site Administration / Notifications / Mobile.'; $string['notificationsnewdevices'] = 'New devices'; $string['notificationsseemore'] = 'Note: Moodle app usage statistics are not calculated in real time. To access more detailed statistics, including data from previous months, please log in to the Moodle Apps Portal.'; $string['notificationssentnotifications'] = 'Notifications sent'; diff --git a/admin/tool/mobile/settings.php b/admin/tool/mobile/settings.php index 59e0128f24ab7..90de327e94095 100644 --- a/admin/tool/mobile/settings.php +++ b/admin/tool/mobile/settings.php @@ -124,10 +124,10 @@ new lang_string('enablesmartappbanners_desc', 'tool_mobile'), 0)); $temp->add(new admin_setting_configtext('tool_mobile/iosappid', new lang_string('iosappid', 'tool_mobile'), - new lang_string('iosappid_desc', 'tool_mobile'), '633359593', PARAM_ALPHANUM)); + new lang_string('iosappid_desc', 'tool_mobile'), tool_mobile\api::DEFAULT_IOS_APP_ID, PARAM_ALPHANUM)); $temp->add(new admin_setting_configtext('tool_mobile/androidappid', new lang_string('androidappid', 'tool_mobile'), - new lang_string('androidappid_desc', 'tool_mobile'), 'com.moodle.moodlemobile', PARAM_NOTAGS)); + new lang_string('androidappid_desc', 'tool_mobile'), tool_mobile\api::DEFAULT_ANDROID_APP_ID, PARAM_NOTAGS)); $temp->add(new admin_setting_configtext('tool_mobile/setuplink', new lang_string('setuplink', 'tool_mobile'), new lang_string('setuplink_desc', 'tool_mobile'), 'https://download.moodle.org/mobile', PARAM_URL));