It is possible to block specific feature plugins for a specific Kapsel app using the Settings plugin and configuring some settings in the SMP Administration and Monitoring tool (cockpit). The SMP help pages define feature plugins as "typically JavaScript APIs that provide access to the native APIs of the mobile device (implemented as Apache Cordova plugins, for example, camera, calendar, and push)."
Today, it is possible to restrict feature plugins just for Android and iOS. Windows support is coming soon.
For native apps, in the future, it will be possible to get the feature policies information via APIs. Wait for news.
Changing the Feature Restriction Policies
If you want to restrict or allow a feature plugin, you should click on the name of the desired feature plugin. Then select the Allowed checkbox if you want to allow this feature plugin to work, or unselect this checkbox if you want to block it. Click on Save and then on Save again. It is ready!
Warning: a simple settings exchange should be enough for having your Kapsel app client applying the changes in the feature restriction policies you have just set. However, if you block a feature policy and then allow it to work again, you will need to close and open your Kapsel app client.
When the Kapsel starts a settings exchange after you blocked a feature plugin, it does two things:
If you allow this same feature plugin to work again and perform a settings exchange, it is not in the disabled list anymore. However this plugin namespace is still null. This null value will be reset only when the page refresh happens and cordova reloads the plugin namespace.
So you will have to close the app and start it again to give cordova a chance to refresh all the namespaces.
You also can add other Kapsel or Cordova plugins to the list to block them. For that, you just have to click on the Add button, fill out the fields with information of the feature plugin you want to add and click on Save > Save.
Settings Exchange
As explained above, a settings exchange needs to be performed in order to have the Kapsel app client synchronized with feature policies set in SMP Administration and Monitoring tool (cockpit).
You can do so using the start API of the Kapsel settings plugin. You first need to pass a connection data variable with the settings to be set to the SMP Server, then success and error callbacks.
Check the index.html file attached here for an example.
For more information, please check the SMP SDK Help Portal.
The work the developer needs to do
As written above, when a feature plugin is restricted (blocked) in SMP Administration and Monitoring tool (cockpit) and settings exchange is performed from the Kapsel app client, the feature plugin namespace is set to null, preventing it to work. So, if a client tries to use this plugin, an error will occur. In order to avoid this, settings plugin has an API to check if a feature plugin is enabled or not: isFeatureEnabled.
The first parameter to be passed is a string with the name of the feature to be checked. Then success and error callbacks should be passed.
In the success callback, one parameter is received with a boolean information representing if the feature is enabled (true) or not (false).
See below the example that Daniel van Leeuwen presented in his SCN Document.
function pickContact() {
//first check if the feature is enabled
sap.Settings.isFeatureEnabled("navigator.contacts", isPickContactEnabledCallback, errorCallback);
}
function isPickContactEnabledCallback(enabled) {
if (enabled) {
navigator.contacts.pickContact(contactPickedCallback, errorCallback);
}
else {
alert("The Contacts Plugin has been disabled by the feature restriction policy");
}
}
function contactPickedCallback(contact) {
alert("The following Conact was selected: " + JSON.stringify(contact));
}
function errorCallback(error) {
alert(JSON.stringify(error));
}
For more information, please check the SMP SDK Help Portal.
Creating a sample app
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
18 | |
16 | |
12 | |
11 | |
9 | |
8 | |
8 | |
8 | |
7 | |
7 |