2 // This file is part of Moodle - http://moodle.org/
4 // Moodle is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
9 // Moodle is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License
15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
18 * Web manifest for including a native app banner.
20 * The banner is only displayed if the user has visited the site twice over two
21 * separate days during the course of two weeks. There is an experimental chrome
22 * flag to allow testing.
23 * More information here: https://developer.android.com/distribute/users/banners.html
25 * @package tool_mobile
26 * @copyright 2017 Juan Leyva
27 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
30 define('NO_DEBUG_DISPLAY', true);
31 define('NO_MOODLE_COOKIES', true);
33 require_once(__DIR__
. '/../../../config.php');
36 header('Content-Type: application/json; charset: utf-8');
38 $mobilesettings = get_config('tool_mobile');
39 // Display manifest contents only if all the required conditions are met.
40 if (!empty($CFG->enablemobilewebservice
) && !empty($mobilesettings->enablesmartappbanners
) &&
41 !empty($mobilesettings->androidappid
)) {
43 $manifest = new StdClass
;
44 $manifest->short_name
= format_string($SITE->shortname
);
45 $manifest->prefer_related_applications
= true;
46 $manifest->icons
= [(object)
49 'type' => 'image/png',
50 'src' => "$CFG->wwwroot/$CFG->admin/tool/mobile/pix/icon_144.png"
53 $manifest->related_applications
= [(object)
56 'id' => $mobilesettings->androidappid
,
59 echo json_encode($manifest);