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
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.
The SDK attempts to refresh the configuration on every cold launch to ensure it stays up to date with the remote configuration.
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.
As best practice, you should configure a mobile property in the Data Collection UI and use environment IDs to configure your application. Follow the steps in the tutorial on setting up a mobile property if you need to create a new Experience Platform App.
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 use this API to load the configuration from the JSON configuration file in the app's Assets folder.
This will replace any configuration previously loaded during app launch or with the configureWithAppID API.
configureWithFileInPath
You can use this API to load the configuration from the bundled JSON configuration file in your app package.
This will replace any configuration previously loaded during app launch or with the configureWithAppID API.
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];