Skip to content

Commit 95808b0

Browse files
author
“Akshay
committed
Merge branch 'feature/embedded/manager' into Encryption-With-Embedded-Manager
2 parents 403f500 + a11a2fa commit 95808b0

File tree

3 files changed

+25
-50
lines changed

3 files changed

+25
-50
lines changed

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

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -571,15 +571,6 @@ public IterableInAppManager getInAppManager() {
571571
return inAppManager;
572572
}
573573

574-
@NonNull
575-
public IterableEmbeddedManager getEmbeddedManager() {
576-
if (embeddedManager == null) {
577-
throw new RuntimeException("IterableApi must be initialized before calling getFlexManager(). " +
578-
"Make sure you call IterableApi#initialize() in Application#onCreate");
579-
}
580-
return embeddedManager;
581-
}
582-
583574
@NonNull
584575
public IterableEmbeddedManager embeddedManager() {
585576
if (embeddedManager == null) {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public final class IterableConstants {
7474
public static final String ENDPOINT_UPDATE_USER_SUBS = "users/updateSubscriptions";
7575
public static final String ENDPOINT_TRACK_INAPP_CLOSE = "events/trackInAppClose";
7676
public static final String ENDPOINT_GET_REMOTE_CONFIGURATION = "mobile/getRemoteConfiguration";
77-
public static final String ENDPOINT_GET_EMBEDDED_MESSAGES = "flex/messages";
77+
public static final String ENDPOINT_GET_EMBEDDED_MESSAGES = "embedded-messaging/messages";
7878

7979
public static final String PUSH_APP_ID = "IterableAppId";
8080
public static final String PUSH_GCM_PROJECT_NUMBER = "GCMProjectNumber";

iterableapi/src/main/java/com/iterable/iterableapi/IterableEmbeddedManager.kt

Lines changed: 24 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -202,29 +202,33 @@ public class IterableEmbeddedManager: IterableActivityMonitor.AppStateCallback{
202202

203203
fun scheduleSync() {
204204
IterableLogger.printInfo()
205-
if (canSyncEmbeddedMessages()) {
206-
IterableLogger.v(TAG, "Can sync now.. Syncing now")
207-
IterableLogger.v(TAG, "setting isSyncScheduled to false in first if")
208-
getSyncedEmbeddedMessages()
205+
if(autoFetchDuration > 0) {
206+
if (canSyncEmbeddedMessages()) {
207+
IterableLogger.v(TAG, "Can sync now.. Syncing now")
208+
IterableLogger.v(TAG, "setting isSyncScheduled to false in first if")
209+
getSyncedEmbeddedMessages()
209210

210-
} else {
211-
if (!isAppInBackground) {
212-
IterableLogger.v(
213-
TAG,
214-
"Scheduling sync after ${autoFetchDuration - getSecondsSinceLastFetch()} seconds"
215-
)
216-
Handler(Looper.getMainLooper()).postDelayed(
217-
{
218-
getSyncedEmbeddedMessages()
219-
IterableLogger.v(TAG, "inside looper setting isSyncScheduled to false")
220-
},
221-
((autoFetchDuration - getSecondsSinceLastFetch()) * 1000).toLong()
222-
)
223-
IterableLogger.v(TAG, "setting isSyncScheduled to true")
224211
} else {
225-
IterableLogger.v(TAG, "Not scheduling a sync.. App is in background")
226-
lastSync = autoFetchDuration.toLong()
212+
if (!isAppInBackground) {
213+
IterableLogger.v(
214+
TAG,
215+
"Scheduling sync after ${autoFetchDuration - getSecondsSinceLastFetch()} seconds"
216+
)
217+
Handler(Looper.getMainLooper()).postDelayed(
218+
{
219+
getSyncedEmbeddedMessages()
220+
IterableLogger.v(TAG, "inside looper setting isSyncScheduled to false")
221+
},
222+
((autoFetchDuration - getSecondsSinceLastFetch()) * 1000).toLong()
223+
)
224+
IterableLogger.v(TAG, "setting isSyncScheduled to true")
225+
} else {
226+
IterableLogger.v(TAG, "Not scheduling a sync.. App is in background")
227+
lastSync = autoFetchDuration.toLong()
228+
}
227229
}
230+
} else {
231+
IterableLogger.v(TAG, "embedded messaging automatic fetching not started since autoFetchDuration is <= 0")
228232
}
229233
}
230234

@@ -238,26 +242,6 @@ public class IterableEmbeddedManager: IterableActivityMonitor.AppStateCallback{
238242

239243
// endregion
240244

241-
// region basic test methods
242-
243-
//For testing purpose only
244-
fun getMessagesFromJson(): List<IterableEmbeddedMessage> {
245-
val file = File("data.json")
246-
val bufferedReader = file.bufferedReader()
247-
val jsonString = bufferedReader.use { it.readText() }
248-
val messageJson = JSONObject(jsonString)
249-
250-
val embeddedMessages = listOf(
251-
IterableEmbeddedMessage.fromJSONObject(messageJson),
252-
IterableEmbeddedMessage.fromJSONObject(messageJson),
253-
IterableEmbeddedMessage.fromJSONObject(messageJson)
254-
)
255-
256-
return embeddedMessages
257-
}
258-
259-
// endregion
260-
261245
// region IterableActivityMonitor.AppStateCallback
262246
override fun onSwitchToForeground() {
263247
IterableLogger.printInfo()

0 commit comments

Comments
 (0)