Skip to content

Commit e0d5bfc

Browse files
author
Rodrigo Gomez Palacio
committed
Delay the IAM fetch by rywDelay w/ fallback
Motivation: make use of the new object to pull out the `rywDelay` value & delay by that amount. By doing so we help minimize the number of retries that will hit the backend.
1 parent 6f3a48f commit e0d5bfc

File tree

1 file changed

+5
-0
lines changed
  • OneSignalSDK/onesignal/in-app-messages/src/main/java/com/onesignal/inAppMessages/internal/backend/impl

1 file changed

+5
-0
lines changed

OneSignalSDK/onesignal/in-app-messages/src/main/java/com/onesignal/inAppMessages/internal/backend/impl/InAppBackendService.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ import com.onesignal.inAppMessages.internal.hydrators.InAppHydrator
1414
import kotlinx.coroutines.delay
1515
import org.json.JSONObject
1616

17+
private const val DEFAULT_RYW_DELAY_MS = 500L
18+
1719
internal class InAppBackendService(
1820
private val _httpClient: IHttpClient,
1921
private val _deviceService: IDeviceService,
@@ -27,6 +29,9 @@ internal class InAppBackendService(
2729
rywToken: String?,
2830
sessionDurationProvider: () -> Long,
2931
): List<InAppMessage>? {
32+
val rywDelay = rywData.rywDelay ?: DEFAULT_RYW_DELAY_MS
33+
delay(rywDelay) // Delay by the specified amount
34+
3035
val baseUrl = "apps/$appId/subscriptions/$subscriptionId/iams"
3136
return attemptFetchWithRetries(baseUrl, rywToken, sessionDurationProvider)
3237
}

0 commit comments

Comments
 (0)