-
Notifications
You must be signed in to change notification settings - Fork 0
IL-15906: Proper passing of parameters to packaged app #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| // 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) { |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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": { |
There was a problem hiding this comment.
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.
This change adds code in the
onLaunchedevent 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.