Skip to content
This repository was archived by the owner on Aug 28, 2023. It is now read-only.

Commit bb6ee81

Browse files
authored
v1.1.1 Always resolve start promise when called multiple times, update libs (#41)
* First run at multiple start call fix * 1.1.1
1 parent e2cdfde commit bb6ee81

4 files changed

Lines changed: 26 additions & 9 deletions

File tree

android/src/main/java/com/adobe/marketing/mobile/reactnative/RCTACPCoreModule.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,17 @@
2323
import com.facebook.react.bridge.ReactApplicationContext;
2424
import com.facebook.react.bridge.ReactContextBaseJavaModule;
2525
import com.facebook.react.bridge.ReactMethod;
26-
import com.facebook.react.bridge.Callback;
2726
import com.facebook.react.bridge.ReadableMap;
2827

29-
import android.app.Activity;
3028
import android.app.Application;
31-
import android.util.Log;
29+
30+
import java.util.concurrent.atomic.AtomicBoolean;
3231

3332
public class RCTACPCoreModule extends ReactContextBaseJavaModule {
3433

3534
private final ReactApplicationContext reactContext;
3635
private static String FAILED_TO_CONVERT_EVENT_MESSAGE = "Failed to convert map to Event";
36+
private static AtomicBoolean hasStarted = new AtomicBoolean(false);
3737

3838
public RCTACPCoreModule(ReactApplicationContext reactContext) {
3939
super(reactContext);
@@ -58,10 +58,16 @@ public void extensionVersion(final Promise promise) {
5858

5959
@ReactMethod
6060
public void start(final Promise promise) {
61+
if (hasStarted.get()) {
62+
promise.resolve(true);
63+
return;
64+
}
65+
6166
MobileCore.start(new AdobeCallback() {
6267
@Override
6368
public void call(Object obj) {
64-
promise.resolve(true);
69+
hasStarted.set(true);
70+
promise.resolve(true);
6571
}
6672
});
6773
}

ios/src/Core/RCTACPCore.m

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,20 @@ - (NSData *)dataFromHexString:(NSString *)string {
5454
}
5555

5656
RCT_EXPORT_METHOD(start: (RCTPromiseResolveBlock) resolve rejecter:(RCTPromiseRejectBlock)reject) {
57-
[ACPCore start:^{
58-
resolve(@(YES));
59-
}];
57+
static BOOL hasStarted = NO;
58+
static dispatch_once_t onceToken;
59+
60+
if (hasStarted) {
61+
resolve(@(hasStarted));
62+
return;
63+
}
64+
65+
dispatch_once(&onceToken, ^{
66+
[ACPCore start:^{
67+
hasStarted = YES;
68+
resolve(@(hasStarted));
69+
}];
70+
});
6071
}
6172

6273
RCT_EXPORT_METHOD(configureWithAppId:(NSString* __nullable) appId) {

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@adobe/react-native-acpcore",
3-
"version": "1.1.0",
3+
"version": "1.1.1",
44
"description": "Adobe Experience Platform support for React Native apps.",
55
"homepage": "https://aep-sdks.gitbook.io/docs/",
66
"license": "Apache-2.0",

0 commit comments

Comments
 (0)