Managing Assets

JS SDK comes with configurable options that enables developers to switch the working environment easily.

While downloading the SDK, imi-environments.js file comes pre configured with ‘default’ environment. The ‘default’ environment is based upon your setup at the platform.

This file can host multiple environments in JSON format.

var imiEnvironments = {
  target: "default",
  default:
  {
    "asset": {
      "appId": '< your App ID here>',
      "appSecret": '< your secret here>',
      "pathConfig": {
        "assetPath": "/assets/",
        "root": "/"
      }
    },
    "imiclient": {
      "shouldRequestNotificationPermission": true
  },
ParametersDescription
targetSpecifies the current target environment for JS SDK. The environments are defined locally within the same file.
pathConfigIf the website is hosted within a sub-folder, use pathConfig parameter to specify folders:
//Example
var pathConfig = {
"assets": "/website_root/assets/",
"root": "/ website_root/"
}
pathConfig.assetsFolder ‘assets’ is the relative path to JS SDK including ‘manifest’ folder. By default, this location is derived as
window.location.origin + '/assets';
//Sample Code:
"assets": "/website_root/assets/",
pathConfig.rootFolder containing ‘sw.j’s file.
Important! ‘sw.js’ file should always be in website root for Push notifications to work properly.
shouldRequestNotificationPermissionIf true, will enable SDK to call requestPushPermission when register() API is called.

If false, SDK will not request push permission when register() API is called. Developer needs to explicitly call SDK’s requestPushPermission() API on user interaction.