Requesting a shared state that is not tied to an event
Extensions can skip passing the ACPExtensionEvent (iOS) / Event (Android) parameter to the getSharedEventState method. If no state is available, the SDK returns the latest available shared state or a null value.
The caller must be careful to account for null values being passed back.
Android
iOS

Java

1
@Override
2
public void onUnregistered() {
3
ExtensionErrorCallback<ExtensionError> errorCallback = new ExtensionErrorCallback<ExtensionError>() {
4
@Override
5
public void error(final ExtensionError extensionError) {
6
Log.e("MyExtension", String.format("An error occurred while retrieving the shared state for configuration %d %s", extensionError.getErrorCode(), extensionError.getErrorName()));
7
}
8
};
9
10
Map<String, Object> configurationSharedState = getApi().getSharedEventState("com.adobe.module.configuration", null, errorCallback);
11
Log.d("MyExtension", String.format("Latest configuration was: %s", configurationSharedState));
12
...
13
}
Copied!

Objective-C

1
- (void) onUnregister {
2
NSError* error = nil;
3
NSDictionary* configurationSharedState = [self.api getSharedEventState:@"com.adobe.module.configuration" event:nil error:&error];
4
if (configurationSharedState) {
5
NSLog(@"The configuration when onUnregister was called was \n:%@", configurationSharedState);
6
}
7
}
Copied!
Last modified 3mo ago
Export as PDF
Copy link