This plugin provides a native settings page for an app. The settings screen can be shown by calling
sap.AppPreferences.showPreferencesScreen(successCallback, errorCallback);
In versions prior to SP05 SDK PL03, the showPreferenceScreen method only supported Android. On iOS, the user had to go to the iOS settings screen to view the settings. It now works for Android and iOS.
The settings are specified by calling
sap.AppPreferences.configurePreferencesScreen(preferencesJSON, successCallback, errorCallback);
where preferencesJSON describes the settings to be shown.
On Android, the settings values can be validated by including JavaScript code in a validation.html file as shown in the example below. On iOS, the values can be validated via the regex field in the JSON.
The values can be accessed and modified programmatically by calling
sap.AppPreferences.getPreferenceValue(key, successCallback, errorCallback);
and
sap.AppPreferences.setPreferenceValue(key, value, successCallback, errorCallback);
For additional details on the apppreferences plugin see the JavaScript file in a project that includes this plugin at
project_name\plugins\com.sap.mp.cordova.plugins.apppreferences\www\apppreferences.js
or the JS Documentation at Kapsel Application Preferences API Reference.
The following steps will demonstrate an example of using this plugin.
cordova -d create C:\Kapsel_Projects\AppPreferencesDemo com.mycompany.apppreferences AppPreferencesDemo "{\"plugin_search_path\":\"C:/SAP/MobileSDK3/KapselSDK/plugins/\"}"
cd C:\Kapsel_Projects\AppPreferencesDemo
cordova -d platform add android
cordova -d create ~/Documents/Kapsel_Projects/AppPreferencesDemo com.mycompany.apppreferences AppPreferencesDemo "{\"plugin_search_path\":\"/Users/i826567/SAP/MobileSDK3/KapselSDK/plugins/\"}"
cd ~/Documents/Kapsel_Projects/AppPreferencesDemo
cordova -d platform add ios
cordova -d plugin add com.sap.mp.cordova.plugins.apppreferences
cordova -d prepare
C:\SAP\MobileSDK3\KapselSDK\apps\fiori_client\assets\Root.plist
In Xcode, right-click on AppPreferencesDemo > Resources > Settings.bundle > Root.plist and choose Open As > Source Code. Copy the contents from the Fiori client sample Root.plist. See also Settings Application Schema Reference."defaultvalue" : "true"
must be changed to"defaultvalue" : true
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
36 | |
25 | |
17 | |
13 | |
8 | |
7 | |
6 | |
6 | |
6 | |
6 |