Moodle App Deep Linking: Difference between revisions
- Moodle App Overview
- Moodle App Development Guide
- Moodle App Plugins Development Guide
- Moodle App Remote Themes
- Moodle App Customisation
- Setting up your development environment
- Using the Moodle App in a browser
- Moodle App Translation
- Moodle App FAQ
- Moodle App Development Process
- Moodle App Release Notes
Upgrade from previous versions:
- See all Moodle App pages
- See pages for Moodle App Ionic 5 (current)
- See pages for Moodle App Ionic 3 (legacy)
- See pages Moodle App Ionic 1 (legacy)
- See pages for Moodle App Phonegap (legacy)
For user documentation see Moodle Mobile
No edit summary |
Dev Docs Bot (talk | contribs) (Update migration status and path) |
||
(13 intermediate revisions by 6 users not shown) | |||
Line 1: | Line 1: | ||
{{ | {{Template:Migrated|newDocId=/general/app/development/link-handling/deep-linking}} | ||
{{Moodle App | {{Moodle App (Ionic 5)}} | ||
== Overview == | == Overview == | ||
The Moodle | The Moodle App supports being launched using a Custom URL Scheme. It lets 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. For example, if you click one of these links in Safari in an iOS device without the app installed, an error will be displayed. | |||
If you are using a custom Moodle App you have to change <code>moodlemobile://</code> to your custom URL scheme. If you are using a [https://moodle.com/branded-app BMA (Branded Moodle App)], please contact your [https://moodle.com/services Moodle Service Provider (Moodle partner)] for this information. | |||
== Format == | == Format == | ||
The | The format to create the links is the following: | ||
< | <syntaxhighlight lang="text"> | ||
moodlemobile://https://username@domain.com?token=TOKEN&privatetoken=PRIVATETOKEN&redirect=http://domain.com/course/view.php?id=2 | |||
</syntaxhighlight> | |||
The only data required is the base URL of your site (in the example above, <code>https://domain.com</code>). | The only data required is the base URL of your site (in the example above, <code>https://domain.com</code>). | ||
Line 22: | Line 22: | ||
=== Site URL === | === Site URL === | ||
As mentioned above, this is the only required | As mentioned above, this is the only required parameter. It should be the base URL of the site (wwwroot). For example, you can use this URL to open your site in the app: | ||
< | <syntaxhighlight lang="text"> | ||
moodlemobile://https://domain.com | |||
</syntaxhighlight> | |||
In the example above, if the | In the example above, if the <code>https://domain.com</code> site isn't stored in the app, the user will be redirected to the credentials screen to access the site. | ||
=== Username === | === Username === | ||
Line 32: | Line 34: | ||
If you want the app to be opened with a certain username you can specify it in the URL: | If you want the app to be opened with a certain username you can specify it in the URL: | ||
< | <syntaxhighlight lang="text"> | ||
moodlemobile://https://username@domain.com | |||
</syntaxhighlight> | |||
In the example above, if the | In the example above, if the <code>username</code> user and the <code>https://domain.com</code> site aren'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 === | === 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, | 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. For example, you can use this feature for SSO systems. The user token can be found in the database table <code>mdl_external_tokens</code>. | ||
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 | 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 private token but not a token, the private token will be ignored. The private token can also be found in the database table <code>mdl_external_tokens</code>. | ||
It isn't recommended to include the token and | It isn't recommended to include the token and private token 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. | ||
Example: | Example: | ||
< | <syntaxhighlight lang="text"> | ||
moodlemobile://https://domain.com?token=TOKEN&privatetoken=PRIVATETOKEN | |||
</syntaxhighlight> | |||
The token has priority over the username parameter. | The token has priority over the username parameter. For example, if you specify username "u1" but the token belongs to user "u2", the user u2 will be authenticated in the app. | ||
=== Redirect === | === Redirect === | ||
The redirect parameter indicates which page you want to open in the app | The redirect parameter indicates which page you want to open in the app: | ||
< | <syntaxhighlight lang="text"> | ||
moodlemobile://https://domain.com?redirect=http://domain.com/course/view.php?id=2 | |||
</syntaxhighlight> | |||
This link will open the course with | 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. | The redirect URL should belong to the same site as the base URL. For example, if the base URL is <code>http://domain.com</code> but the redirect is <code>http://anothersite.com/...</code>, 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: | The redirect parameter can be a relative URL based on the base URL. The example above can also be written like this: | ||
< | <syntaxhighlight lang="text"> | ||
moodlemobile://https://domain.com?redirect=/course/view.php?id=2 | |||
</syntaxhighlight> | |||
== Before 3.7 == | |||
Deep linking was introduced in version 3.6.1, but it had a different format that was updated in 3.7.0 to the one we use today. | |||
This is an example of the previous format: | |||
<syntaxhighlight lang="text"> | |||
moodlemobile://link=https://mysite.es/mod/choice/view.php?id=8 | |||
</syntaxhighlight> | |||
== See also == | == See also == | ||
[https://github.com/EddyVerbruggen/Custom-URL-scheme Custom URL Scheme Cordova plugin used by the app] | * [https://github.com/EddyVerbruggen/Custom-URL-scheme Custom URL Scheme Cordova plugin used by the app]. |
Latest revision as of 10:56, 30 September 2022
Important:
This content of this page has been updated and migrated to the new Moodle Developer Resources. The information contained on the page should no longer be seen up-to-date. Why not view this page on the new site and help us to migrate more content to the new site! |
Overview
The Moodle App supports being launched using a Custom URL Scheme. It lets 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. For example, if you click one of these links in Safari in an iOS device without the app installed, an error will be displayed.
If you are using a custom Moodle App you have to change moodlemobile://
to your custom URL scheme. If you are using a BMA (Branded Moodle App), please contact your Moodle Service Provider (Moodle partner) for this information.
Format
The format to create the links is the following:
moodlemobile://https://username@domain.com?token=TOKEN&privatetoken=PRIVATETOKEN&redirect=http://domain.com/course/view.php?id=2
The only data required is the base URL of your site (in the example above, https://domain.com
).
Site URL
As mentioned above, this is the only required parameter. 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.com
In the example above, if the https://domain.com
site isn't stored in the app, the user will be redirected to the credentials screen to access the site.
Username
If you want the app to be opened with a certain username you can specify it in the URL:
moodlemobile://https://username@domain.com
In the example above, if the username
user and the https://domain.com
site aren'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. For example, 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 private token but not a token, the private token 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 private token 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.
Example:
moodlemobile://https://domain.com?token=TOKEN&privatetoken=PRIVATETOKEN
The token has priority over the username parameter. For example, if you specify username "u1" but the token belongs to user "u2", the user u2 will be authenticated in the app.
Redirect
The redirect parameter indicates which page you want to open in the app:
moodlemobile://https://domain.com?redirect=http://domain.com/course/view.php?id=2
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. For example, if the base URL is http://domain.com
but 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:
moodlemobile://https://domain.com?redirect=/course/view.php?id=2
Before 3.7
Deep linking was introduced in version 3.6.1, but it had a different format that was updated in 3.7.0 to the one we use today.
This is an example of the previous format:
moodlemobile://link=https://mysite.es/mod/choice/view.php?id=8