Configuration API reference
clearUpdatedConfiguration
You can clear any programmatic updates made to the configuration via the clearUpdatedConfiguration API. This will clear programmatic updates to configuration made via the updateConfiguration API. It will also clear any updates to the MobilePrivacyStatus(Android)/ PrivacyStatus(iOS) made via setPrivacyStatus.
Here are some scenarios based on the order of calls:
- configureWithAppId
- updateConfiguration
- clearUpdatedConfiguration
Result: You end up with the initial configuration set via configureWithAppId.
- configureWithFileInPath
- updateConfiguration
- clearUpdatedConfiguration
Result: You end up with the initial configuration set via configureWithFileInPath.
- configureWithAppId or configureWithFileInPath or configureWithFileInAssets
- updateConfiguration
- clearUpdatedConfiguration
- updateConfiguration
Result: In this example, the configuration will be the most recently updated configuration and will not have any keys from the first update unless they are included in the most recent update.
- configureWithAppId or configureWithFileInPath or configureWithFileInAssets
- setPrivacyStatus
- clearUpdatedConfiguration
Result: In this example, the configuration will have the initial MobilePrivacyStatus(Android)/ PrivacyStatus(iOS) set via configureWithAppId or configureWithFileInPath or configureWithFileInAssets.
Android Java
data-slots=heading, code
data-repeat=2
Syntax
public static void clearUpdatedConfiguration();
Example
MobileCore.clearUpdatedConfiguration();
iOS Swift
data-slots=heading, code
data-repeat=2
Syntax
static func clearUpdatedConfiguration()
Example
MobileCore.clearUpdatedConfiguration()
iOS Objective-C
data-slots=heading, code
data-repeat=2
Syntax
+ (void) clearUpdatedConfiguration();
Example
[AEPMobileCore clearUpdatedConfiguration];
configureWithAppID
You can use this API to download and apply the remote configuration for the provided app ID to the current session. Once downloaded, the configuration is stored in the local cache to prevent unnecessary downloads. The configuration is fetched only if remote changes are detected.
data-variant=info
data-slots=text
When you configure a mobile property, a unique environment ID is generated that the SDK uses to retrieve your configuration. The remote configuration is available when an app configuration is created and published to a given environment.
data-variant=success
data-slots=text
Android Java
data-slots=heading, code
data-repeat=2
Syntax
public static void configureWithAppID(@NonNull final String appId);
Example
MobileCore.configureWithAppId("1423ae38-8385-8963-8693-28375403491d");
iOS Swift
data-slots=heading, code
data-repeat=2
Syntax
static func configureWith(appId: String)
Example
MobileCore.configureWith(appId: "1423ae38-8385-8963-8693-28375403491d")
iOS Objective-C
data-slots=heading, code
data-repeat=2
Syntax
+ (void) configureWithAppId: (NSString* appId);
Example
[AEPMobileCore configureWithAppId: @"1423ae38-8385-8963-8693-28375403491d"];
configureWithFileInAssets
data-variant=info
data-slots=text
You can use this API to load the configuration from the JSON configuration file in the app's Assets folder.
data-variant=warning
data-slots=text
Android Java
data-slots=heading, code
data-repeat=2
Syntax
public static void configureWithFileInAssets(@NonNull final String fileName);
Example
MobileCore.configureWithFileInAssets("exampleJSONfile.json");
configureWithFileInPath
You can use this API to load the configuration from the bundled JSON configuration file in your app package.
data-variant=warning
data-slots=text
To pass in a bundled path and file name:
Android Java
data-slots=heading, code
data-repeat=2
Syntax
public static void configureWithFileInPath(@NonNull final String filePath);
Example
MobileCore.configureWithFileInPath("absolute/path/to/exampleJSONfile.json");
iOS Swift
data-slots=heading, code
data-repeat=2
Syntax
static func configureWith(filePath: String)
Example
let filePath = Bundle.main.path(forResource: "ExampleJSONFile", ofType: "json")
MobileCore.configureWith(filePath: filePath)
iOS Objective-C
data-slots=heading, code
data-repeat=2
Syntax
+ (void) configureWithFileInPath: (NSString* __nullable) filepath;
Example
NSString *filePath = [[NSBundle mainBundle] pathForResource:@"ExampleJSONFile" ofType:@"json"];
[AEPMobileCore configureWithFilePath:filePath];
extensionVersion
The extensionVersion() API returns the version of the Configuration extension.
To get the version of the Configuration extension, use the following code sample:
Android Java
String coreExtensionVersion = MobileCore.extensionVersion();
iOS Swift
let version = MobileCore.extensionVersion
iOS Objective-C
NSString *version = [AEPMobileCore extensionVersion];
updateConfiguration
You can also update the configuration programmatically by passing configuration keys and values to override the existing configuration.
data-variant=info
data-slots=text
data-variant=warning
data-slots=text
build.environment key or any key with an environment prefix, because it can lead to unexpected behaviors. For more information, read Environment-aware configuration properties.Android Java
data-slots=heading, code
data-repeat=2
Syntax
public static void updateConfiguration(@NonNull final Map configMap);
Example
HashMap<String, Object> data = new HashMap<String, Object>();
data.put("global.privacy", "optedout");
MobileCore.updateConfiguration(data);
iOS Swift
data-slots=heading, code
data-repeat=2
Syntax
@objc(updateConfiguration:)
static func updateConfigurationWith(configDict: [String: Any])
Example
let updatedConfig = ["global.privacy":"optedout"]
MobileCore.updateConfigurationWith(configDict: updatedConfig)
iOS Objective-C
data-slots=heading, code
data-repeat=2
Syntax
+ (void) updateConfiguration: (NSDictionary* __nullable) config;
Example
NSDictionary *updatedConfig = @{@"global.privacy":@"optedout"};
[AEPMobileCore updateConfiguration:updatedConfig];