Skip to content

Conversation

@ericgibby
Copy link

This change adds code in the onLaunched event listener to record the URL used to launch the app via the URL handler. That URL is then stored in local storage so it can be retrieved along with server settings when the web view is loaded, passing the original parameters on to the WebGL app.

// We only want the data that comes after the base URL, specified by the ID
// of the url_handler.
var relativeUrl;
if (launchData.source === 'url_handler' && launchData.url && launchData.id) {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the app was launched via a URL handler, that info will be passed in the event parameters. The naming convention used for the id properties in the url_handlers section of manifest.json matches the URL used to launch the app, allowing us to remove the unnecessary information from the beginning of the URL and leave just the portion used to pass parameters.


// If we identified a relative URL from the url_handler, we'll stuff
// it in local storage to be retrieved when the app launches.
if (relativeUrl) {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the URL handler was used to launch the app, we'll store the URL parameters in local storage for retrieval later. If not, we'll clear it so it doesn't take the user somewhere unexpected.

navigateTo(url);
}

chrome.storage.local.get('relativeLaunchUrl', function (obj) {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check to see if a launch URL was stored in local storage, so we can combine its parameters with the server settings stored in managed storage.

var queryString = '';
if (serverSettings && serverSettings.cloudSiteCode && serverSettings.cloudSiteCode.length > 0) {
queryString = '?sitecode=' + serverSettings.cloudSiteCode;
function convertServerSettingsToUrl(serverSettings, launchUrl) {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This now includes the original launch URL (if there was one), so those parameters can be passed on to the WebGL app along with the server settings.

},
"url_handlers": {
"openApp": {
"localhost/player": {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The various IDs used make it easier to extract the pertinent information from the URL. It allows us to build a simple regex to remove the beginning of the URL and leave the relevant path and query string info in place.

@ericgibby ericgibby merged commit 07e300a into IL Mar 22, 2017
@ericgibby ericgibby deleted the IL-15906 branch March 22, 2017 15:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants