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.
configureWithAppID
This API causes the SDK to download the configuration for the provided app ID and apply the configuration to the current session.
Swift
Syntax
Copied to your clipboardstatic func configureWith(appId: String)
Example
Copied to your clipboardMobileCore.configureWith(appId: "1423ae38-8385-8963-8693-28375403491d")
Objective-C
Syntax
Copied to your clipboard+ (void) configureWithAppId: (NSString* appId);
Example
Copied to your clipboard[AEPMobileCore configureWithAppId: @"1423ae38-8385-8963-8693-28375403491d"];
Java
Syntax
Copied to your clipboardpublic static void configureWithAppID(@NonNull final String appId);
Example
Copied to your clipboardMobileCore.configureWithAppId("1423ae38-8385-8963-8693-28375403491d");
Swift
Syntax
Copied to your clipboardstatic func configureWith(appId: String)
Example
Copied to your clipboardMobileCore.configureWith(appId: "1423ae38-8385-8963-8693-28375403491d")
Objective-C
Syntax
Copied to your clipboard+ (void) configureWithAppId: (NSString* appId);
Example
Copied to your clipboard[AEPMobileCore configureWithAppId: @"1423ae38-8385-8963-8693-28375403491d"];
configureWithFileInAssets
This API is only available in Android.
You can bundle a JSON configuration file in the app's Assets folder to replace or complement the configuration that was downloaded by using the Configure with App ID per environment approach.
configureWithFileInPath
You can include a bundled JSON configuration file in your app package to replace or complement the configuration that was downloaded by using the Configure with App ID per environment approach.
To pass in a bundled path and file name:
Swift
Syntax
Copied to your clipboardstatic func configureWith(filePath: String)
Example
Copied to your clipboardlet filePath = Bundle.main.path(forResource: "ExampleJSONFile", ofType: "json")MobileCore.configureWith(filePath: filePath)
Objective-C
Syntax
Copied to your clipboard+ (void) configureWithFileInPath: (NSString* __nullable) filepath;
Example
Copied to your clipboardNSString *filePath = [[NSBundle mainBundle] pathForResource:@"ExampleJSONFile" ofType:@"json"];[AEPMobileCore configureWithFilePath:filePath];
Java
Syntax
Copied to your clipboardpublic static void configureWithFileInPath(@NonNull final String filePath);
Example
Copied to your clipboardMobileCore.configureWithFileInPath("absolute/path/to/exampleJSONfile.json");
Swift
Syntax
Copied to your clipboardstatic func configureWith(filePath: String)
Example
Copied to your clipboardlet filePath = Bundle.main.path(forResource: "ExampleJSONFile", ofType: "json")MobileCore.configureWith(filePath: filePath)
Objective-C
Syntax
Copied to your clipboard+ (void) configureWithFileInPath: (NSString* __nullable) filepath;
Example
Copied to your clipboardNSString *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:
updateConfiguration
You can also update the configuration programmatically by passing configuration keys and values to override the existing configuration.
Keys that are not found on the current configuration are added when this method is followed. Null values are allowed and replace existing configuration values.
Do not use this API to update the 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.
Swift
Syntax
Copied to your clipboard@objc(updateConfiguration:)static func updateConfigurationWith(configDict: [String: Any])
Example
Copied to your clipboardlet updatedConfig = ["global.privacy":"optedout"]MobileCore.updateConfigurationWith(configDict: updatedConfig)
Objective-C
Syntax
Copied to your clipboard+ (void) updateConfiguration: (NSDictionary* __nullable) config;
Example
Copied to your clipboardNSDictionary *updatedConfig = @{@"global.privacy":@"optedout"};[AEPMobileCore updateConfiguration:updatedConfig];
Java
Syntax
Copied to your clipboardpublic static void updateConfiguration(@NonNull final Map configMap);
Example
Copied to your clipboardHashMap<String, Object> data = new HashMap<String, Object>();data.put("global.privacy", "optedout");MobileCore.updateConfiguration(data);
Swift
Syntax
Copied to your clipboard@objc(updateConfiguration:)static func updateConfigurationWith(configDict: [String: Any])
Example
Copied to your clipboardlet updatedConfig = ["global.privacy":"optedout"]MobileCore.updateConfigurationWith(configDict: updatedConfig)
Objective-C
Syntax
Copied to your clipboard+ (void) updateConfiguration: (NSDictionary* __nullable) config;
Example
Copied to your clipboardNSDictionary *updatedConfig = @{@"global.privacy":@"optedout"};[AEPMobileCore updateConfiguration:updatedConfig];