Skip to content
Draft
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion Iterable-React-Native-SDK.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Pod::Spec.new do |s|
s.private_header_files = "ios/**/*.h"

# Load Iterables iOS SDK as a dependency
s.dependency "Iterable-iOS-SDK", "6.5.4.1"
s.dependency "Iterable-iOS-SDK", "6.6.1"

# Basic Swift support
s.pod_target_xcconfig = {
Expand Down
15 changes: 15 additions & 0 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
- Iterable API
- `setVisitorUsageTracked`
- `getVisitorUsageTracked`
- `logoutUser`
- `disableDeviceForAllUsers`
- `trackInboxSession`
- Embedded
- `IterableConfig`
- `IterableAPIMobileFrameworkType`
- `expiringAuthTokenRefreshPeriod`
- `eventThresholdLimit`
- `identityResolution`
- `mobileFrameworkInfo`
- Unknown User
- `IterableInAppTriggerType`
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def kotlin_version = getExtOrDefault("kotlinVersion")
dependencies {
implementation "com.facebook.react:react-android"
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
api "com.iterable:iterableapi:3.5.2"
api "com.iterable:iterableapi:3.5.10"
// api project(":iterableapi") // links to local android SDK repo rather than by release
}

Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import com.facebook.react.bridge.WritableMap;
import com.facebook.react.modules.core.DeviceEventManagerModule;

import com.iterable.iterableapi.AuthFailure;
import com.iterable.iterableapi.InboxSessionManager;
import com.iterable.iterableapi.IterableAction;
import com.iterable.iterableapi.IterableActionContext;
Expand Down Expand Up @@ -572,14 +573,47 @@ public String onAuthTokenRequested() {
}
}

@Override
public void onAuthFailure(AuthFailure authFailure) {
// Create a JSON object for the authFailure object
JSONObject messageJson = new JSONObject();
try {
messageJson.put("userKey", authFailure.userKey);
messageJson.put("failedAuthToken", authFailure.failedAuthToken);
messageJson.put("failedRequestTime", authFailure.failedRequestTime);
messageJson.put("failureReason", authFailure.failureReason.name());
WritableMap eventData = Serialization.convertJsonToMap(messageJson);
sendEvent(EventName.handleAuthFailureCalled.name(), eventData);
} catch (JSONException e) {
IterableLogger.v(TAG, "Failed to set authToken");
}
}

public void onAuthFailureFromReadableMap(ReadableMap authFailure) {
// Handle auth failure from ReadableMap (for new architecture)
try {
WritableMap eventData = Arguments.createMap();
eventData.putString("userKey", authFailure.getString("userKey"));
eventData.putString("failedAuthToken", authFailure.getString("failedAuthToken"));
eventData.putDouble("failedRequestTime", authFailure.getDouble("failedRequestTime"));
eventData.putString("failureReason", authFailure.getString("failureReason"));
sendEvent(EventName.handleAuthFailureCalled.name(), eventData);
} catch (Exception e) {
IterableLogger.e(TAG, "Failed to process auth failure from ReadableMap: " + e.getMessage());
}
}

public void pauseAuthRetries(boolean pauseRetry) {
IterableApi.getInstance().pauseAuthRetries(pauseRetry);
}

@Override
public void onTokenRegistrationSuccessful(String authToken) {
IterableLogger.v(TAG, "authToken successfully set");
// MOB-10422: Pass successhandler to event listener
sendEvent(EventName.handleAuthSuccessCalled.name(), null);
}

@Override
public void onTokenRegistrationFailed(Throwable object) {
IterableLogger.v(TAG, "Failed to set authToken");
sendEvent(EventName.handleAuthFailureCalled.name(), null);
Expand Down
23 changes: 18 additions & 5 deletions android/src/main/java/com/iterable/reactnative/Serialization.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import com.iterable.iterableapi.IterableInboxSession;
import com.iterable.iterableapi.IterableLogger;
import com.iterable.iterableapi.RNIterableInternal;
import com.iterable.iterableapi.RetryPolicy;

import org.json.JSONArray;
import org.json.JSONException;
Expand Down Expand Up @@ -94,7 +95,7 @@ static CommerceItem commerceItemFromMap(JSONObject itemMap) throws JSONException
categories[i] = categoriesArray.getString(i);
}
}

return new CommerceItem(itemMap.getString("id"),
itemMap.getString("name"),
itemMap.getDouble("price"),
Expand Down Expand Up @@ -216,9 +217,21 @@ static IterableConfig.Builder getConfigFromReadableMap(ReadableMap iterableConte

configBuilder.setDataRegion(iterableDataRegion);
}

if (iterableContextJSON.has("encryptionEnforced")) {
configBuilder.setEncryptionEnforced(iterableContextJSON.optBoolean("encryptionEnforced"));

// if (iterableContextJSON.has("encryptionEnforced")) {
// configBuilder.setEncryptionEnforced(iterableContextJSON.optBoolean("encryptionEnforced"));
// }

if (iterableContextJSON.has("retryPolicy")) {
JSONObject retryPolicyJson = iterableContextJSON.getJSONObject("retryPolicy");
int maxRetry = retryPolicyJson.getInt("maxRetry");
long retryInterval = retryPolicyJson.getLong("retryInterval");
String retryBackoff = retryPolicyJson.getString("retryBackoff");
RetryPolicy.Type retryPolicyType = RetryPolicy.Type.LINEAR;
if (retryBackoff.equals("EXPONENTIAL")) {
retryPolicyType = RetryPolicy.Type.EXPONENTIAL;
}
configBuilder.setAuthRetryPolicy(new RetryPolicy(maxRetry, retryInterval, retryPolicyType));
}

return configBuilder;
Expand Down Expand Up @@ -286,7 +299,7 @@ static List<IterableInboxSession.Impression> impressionsFromReadableArray(Readab
// ---------------------------------------------------------------------------------------
// region React Native JSON conversion methods
// obtained from https://gist.github.com/viperwarp/2beb6bbefcc268dee7ad

static WritableMap convertJsonToMap(JSONObject jsonObject) throws JSONException {
WritableMap map = new WritableNativeMap();

Expand Down
30 changes: 30 additions & 0 deletions android/src/newarch/java/com/RNIterableAPIModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReadableArray;
import com.facebook.react.bridge.ReadableMap;
import com.iterable.iterableapi.AuthFailure;
import com.iterable.iterableapi.IterableLogger;

public class RNIterableAPIModule extends NativeRNIterableAPISpec {
private final ReactApplicationContext reactContext;
Expand Down Expand Up @@ -217,6 +219,34 @@ public void passAlongAuthToken(@Nullable String authToken) {
moduleImpl.passAlongAuthToken(authToken);
}

@Override
public void onAuthFailure(ReadableMap authFailure) {
// The implementation expects an AuthFailure object, but we need to create one from the ReadableMap
// Since we don't have access to the AuthFailure constructor, we'll need to handle this differently
// For now, let's create a simple approach that matches the expected interface
try {
// Create a mock AuthFailure object with the data from ReadableMap
// This is a workaround since we can't directly instantiate AuthFailure
String userKey = authFailure.getString("userKey");
String failedAuthToken = authFailure.getString("failedAuthToken");
long failedRequestTime = (long) authFailure.getDouble("failedRequestTime");
String failureReasonStr = authFailure.getString("failureReason");

// Create a simple AuthFailure-like object or handle the conversion
// Since we can't access the AuthFailure constructor, we'll need to modify the implementation
// to handle ReadableMap directly or find another approach
moduleImpl.onAuthFailureFromReadableMap(authFailure);
} catch (Exception e) {
// Handle conversion error
IterableLogger.e("RNIterableAPIModule", "Failed to process auth failure: " + e.getMessage());
}
}

@Override
public void pauseAuthRetries(boolean pauseRetry) {
moduleImpl.pauseAuthRetries(pauseRetry);
}

public void sendEvent(@NonNull String eventName, @Nullable Object eventData) {
moduleImpl.sendEvent(eventName, eventData);
}
Expand Down
9 changes: 9 additions & 0 deletions android/src/oldarch/java/com/RNIterableAPIModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,15 @@ public void passAlongAuthToken(@Nullable String authToken) {
moduleImpl.passAlongAuthToken(authToken);
}

@ReactMethod
public void onAuthFailure(AuthFailure authFailure) {
moduleImpl.onAuthFailure(authFailure);
}

@ReactMethod
public void pauseAuthRetries(boolean pauseRetry) {
moduleImpl.pauseAuthRetries(pauseRetry);
}

public void sendEvent(@NonNull String eventName, @Nullable Object eventData) {
moduleImpl.sendEvent(eventName, eventData);
Expand Down
Loading