Skip to content

Commit 122badb

Browse files
committed
add in in-app blob delete when on in memory
1 parent fdf5a84 commit 122badb

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

iterableapi/src/main/java/com/iterable/iterableapi/IterableInAppManager.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import org.json.JSONException;
1818
import org.json.JSONObject;
1919

20+
import java.io.File;
2021
import java.util.ArrayList;
2122
import java.util.Collections;
2223
import java.util.Comparator;
@@ -437,12 +438,24 @@ private void handleIterableCustomAction(String actionName, IterableInAppMessage
437438

438439
private static IterableInAppStorage getInAppStorageModel(IterableApi iterableApi, boolean useInMemoryForInAppStorage) {
439440
if (useInMemoryForInAppStorage) {
441+
checkAndDeleteUnusedInAppFileStorage(iterableApi.getMainActivityContext());
442+
440443
return new IterableInAppMemoryStorage();
441444
} else {
442445
return new IterableInAppFileStorage(iterableApi.getMainActivityContext());
443446
}
444447
}
445448

449+
private static void checkAndDeleteUnusedInAppFileStorage(Context context) {
450+
File sdkFilesDirectory = IterableUtil.getSDKFilesDirectory(context);
451+
File inAppContentFolder = IterableUtil.getDirectory(sdkFilesDirectory, "IterableInAppFileStorage");
452+
File inAppBlob = new File(inAppContentFolder, "itbl_inapp.json");
453+
454+
if (inAppBlob.exists()) {
455+
inAppBlob.delete();
456+
}
457+
}
458+
446459
@Override
447460
public void onSwitchToForeground() {
448461
if (IterableUtil.currentTimeMillis() - lastSyncTime > MOVE_TO_FOREGROUND_SYNC_INTERVAL_MS) {

0 commit comments

Comments
 (0)