Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

package com.appsflyer.reactnative;


Expand Down Expand Up @@ -57,7 +58,7 @@

import static com.appsflyer.reactnative.RNAppsFlyerConstants.*;
import static com.appsflyer.reactnative.RNAppsFlyerConstants.afOnDeepLinking;

import java.util.concurrent.atomic.AtomicBoolean;
public class RNAppsFlyerModule extends ReactContextBaseJavaModule {

private ReactApplicationContext reactContext;
Expand Down Expand Up @@ -323,14 +324,19 @@ public void logEvent(
Activity currentActivity = getCurrentActivity();
if (currentActivity != null) {
AppsFlyerLib.getInstance().logEvent(getCurrentActivity(), eventName, data, new AppsFlyerRequestListener() {
final AtomicBoolean isCompleted = new AtomicBoolean(false);
@Override
public void onSuccess() {
successCallback.invoke(SUCCESS);
if (isCompleted.compareAndSet(false, true)) {
successCallback.invoke(SUCCESS);
}
}

@Override
public void onError(int i, @NonNull String s) {
errorCallback.invoke(s);
if (isCompleted.compareAndSet(false, true)) {
errorCallback.invoke(String.valueOf(i), s);
}
}
});
}
Expand All @@ -355,14 +361,19 @@ public void logEventWithPromise(
Activity currentActivity = getCurrentActivity();
if (currentActivity != null) {
AppsFlyerLib.getInstance().logEvent(getCurrentActivity(), eventName, data, new AppsFlyerRequestListener() {
final AtomicBoolean isCompleted = new AtomicBoolean(false);
@Override
public void onSuccess() {
promise.resolve(SUCCESS);
if (isCompleted.compareAndSet(false, true)) {
promise.resolve(SUCCESS);
}
}

@Override
public void onError(int i, @NonNull String s) {
promise.reject(s);
if (isCompleted.compareAndSet(false, true)) {
promise.reject(String.valueOf(i), s);
}
}
});
}
Expand Down Expand Up @@ -1018,4 +1029,4 @@ public void addListener(String eventName) {
public void removeListeners(Integer count) {
// Keep: Required for RN built in Event Emitter Calls.
}
}
}