Apply Config¶

Once the event listener callback is fired, it will return the new version of the settings. You are then given the chance to decide whether these changes should be applied using the applyConfig() method.

In the previous section, there was a scenario where an end-user modifies the configuration for a storefront’s web application.

Consider the scenario:
  • An end-user is interacting with the Rumba iOS app on an iPad / kiosk in a public storefront.

  • The end-user modifies the configuration for the web application that the storefront has on the iPad.

  • The changes make it difficult for the next user to use the iPad as intended.

Using the example above, it is possible to authorize or reject configuration changes if they do not meet the requirements of your web application.

Here is an example:

// Omitted ...

rumba.addListener('onSettingsChange', (settings) => {
  console.log('the settings have changed: ', settings);

  // Check to see if the settings have undesired properties.
  // (the end-user modified some settings that you,
  // the web developer, prefer to be unchangeable)
  let changed = false;
  if (config.prefix !== "#" ) {
    // return to desired value
    config.prefix = "#";
    changed = true;
  }
  if (config.suffix !== "") {
    // return to desired value
    config.suffix = "";
    changed = true;
  }

  if (config.isNavigationBarVisible !== false) {
    // return to desired value
    config.isNavigationBarVisible;
    changed = true;
  }

  if(changed) {
    // if the end-user made undesired changes, re-save the configuration
    // with the desired settings
    rumba.applyConfig(config);
  }
});

// Omitted ...