Open the Moodle app from another app
Moodle App 3.7
The Moodle app supports being launched using a Custom URL Scheme. In version 3.6.1 or older of the app, the format to do so was:
However, in Moodle app 3.7.0 we introduced a better way to define these links. The new format will let you specify the URL to open, the username to use and also a token to authenticate the user.
Please notice that these links will only work if the app is installed in the device. E.g. if you click one of these links in Safari in an iOS device without the app installed, an error will be displayed.
The new format to create the links is like this:
moodlemobile://https://firstname.lastname@example.org?token=TOKEN&privatetoken=PRIVATETOKEN&redirect=http://domain.com/course/view.php?id=2The only data required is the base URL of your site (in the example above,
As mentioned above, this is the only required param. It should be the base URL of the site (wwwroot). For example, you can use this URL to open your site in the app:
moodlemobile://https://domain.comIn the example above, if the site
https://domain.comisn't stored in the app, the user will be redirected to the credentials screen to access the site.
If you want the app to be opened with a certain username you can specify it in the URL:
moodlemobile://https://email@example.comIn the example above, if the user
usernameand the site
https://domain.comaren't stored in the app, the user will be sent to the credentials screen to access the site (the username input will be prepopulated, but the user will be able to change it if he wants to). If the app has several users of this site stored, including "username", the right user will be loaded.
Token and Private token
If you specify a token in the URL, the user will be authenticated automatically in the app. This is really useful for external apps and systems, e.g. you can use this feature for SSO systems. The user token can be found in the database table "mdl_external_tokens".
The private token is used by the app to auto-login the user in the browser, and it will only be used if you also specify a token in the URL. If you specify a privatetoken but not a token, the privatetoken will be ignored. The private token can also be found in the database table "mdl_external_tokens".
It isn't recommended to include the token and privatetoken in links that will be rendered by a browser or apps that can be inspected. Please notice that anyone with the token will be able to authenticate as the user the token belongs to.
The token has priority over the username parameter. E.g. if you specify username "u1" but the token belongs to user "u2", the user u2 will be authenticated in the app.
The redirect parameter indicates which page you want to open in the app. Example:
This link will open the course with ID=2 in the app. Please notice that the app doesn't support all Moodle URLs, only some of them are supported.The redirect URL should belong to the same site as the base URL. E.g. if the base URL is
http://domain.combut the redirect is
http://anothersite.com/..., an error will be displayed.
The redirect parameter can be a relative URL based on the base URL. The example above can also be written like this: