diff --git a/code/optimize/src/main/java/com/adobe/marketing/mobile/optimize/Optimize.java b/code/optimize/src/main/java/com/adobe/marketing/mobile/optimize/Optimize.java index 40f2204..f9e28db 100644 --- a/code/optimize/src/main/java/com/adobe/marketing/mobile/optimize/Optimize.java +++ b/code/optimize/src/main/java/com/adobe/marketing/mobile/optimize/Optimize.java @@ -49,7 +49,7 @@ private Optimize() {} * Experience Edge network. * *

The returned decision propositions are cached in-memory in the Optimize SDK extension and - * can be retrieved using {@link #getPropositions(List, long, AdobeCallback)} API. + * can be retrieved using {@link #getPropositions(List, AdobeCallback)} API. * * @param decisionScopes {@code List} containing scopes for which offers need to * be updated. @@ -99,7 +99,7 @@ public static void updatePropositions( * Experience Edge network. * *

The returned decision propositions are cached in-memory in the Optimize SDK extension and - * can be retrieved using {@link #getPropositions(List, long, AdobeCallback)} API. + * can be retrieved using {@link #getPropositions(List, double, AdobeCallback)} API. * * @param decisionScopes {@code List} containing scopes for which offers need to * be updated. @@ -278,8 +278,8 @@ public void call(final Event event) { public static void getPropositions( @NonNull final List decisionScopes, @NonNull final AdobeCallback> callback) { - long defaultTimeout = OptimizeConstants.GET_RESPONSE_CALLBACK_TIMEOUT; - getPropositionsInternal(decisionScopes, defaultTimeout, callback); + final double defaultTimeoutSeconds = OptimizeConstants.GET_RESPONSE_CALLBACK_TIMEOUT; + getPropositionsInternal(decisionScopes, defaultTimeoutSeconds, callback); } /** @@ -293,14 +293,14 @@ public static void getPropositions( */ public static void getPropositions( @NonNull final List decisionScopes, - final long timeoutMillis, + final double timeoutSeconds, @NonNull final AdobeCallback> callback) { - getPropositionsInternal(decisionScopes, timeoutMillis, callback); + getPropositionsInternal(decisionScopes, timeoutSeconds, callback); } private static void getPropositionsInternal( @NonNull final List decisionScopes, - final long timeoutMillis, + final double timeoutSeconds, @NonNull final AdobeCallback> callback) { if (OptimizeUtils.isNullOrEmpty(decisionScopes)) { Log.warning( @@ -348,8 +348,8 @@ private static void getPropositionsInternal( .setEventData(eventData) .build(); - // Increased default response callback timeout to 10s to ensure prior update propositions - // requests have enough time to complete. + long timeoutMillis = (long) (timeoutSeconds * 1000); + MobileCore.dispatchEventWithResponseCallback( event, timeoutMillis, diff --git a/code/optimize/src/main/java/com/adobe/marketing/mobile/optimize/OptimizeConstants.java b/code/optimize/src/main/java/com/adobe/marketing/mobile/optimize/OptimizeConstants.java index 6d7aaee..c9933f6 100644 --- a/code/optimize/src/main/java/com/adobe/marketing/mobile/optimize/OptimizeConstants.java +++ b/code/optimize/src/main/java/com/adobe/marketing/mobile/optimize/OptimizeConstants.java @@ -16,8 +16,7 @@ class OptimizeConstants { static final String EXTENSION_VERSION = "3.2.0"; static final String EXTENSION_NAME = "com.adobe.optimize"; static final String FRIENDLY_NAME = "Optimize"; - static final long DEFAULT_RESPONSE_CALLBACK_TIMEOUT = 500L; - static final long GET_RESPONSE_CALLBACK_TIMEOUT = 10000L; + static final double GET_RESPONSE_CALLBACK_TIMEOUT = 10; static final double EDGE_CONTENT_COMPLETE_RESPONSE_TIMEOUT = 10; static final String ACTIVITY_ID = "activityId"; diff --git a/code/testapp/src/main/java/com/adobe/marketing/optimizeapp/OffersScreen.kt b/code/testapp/src/main/java/com/adobe/marketing/optimizeapp/OffersScreen.kt index 2fb686a..19a9ddc 100644 --- a/code/testapp/src/main/java/com/adobe/marketing/optimizeapp/OffersScreen.kt +++ b/code/testapp/src/main/java/com/adobe/marketing/optimizeapp/OffersScreen.kt @@ -203,7 +203,7 @@ fun OffersView(viewModel: MainViewModel) { viewModel.getPropositions( decisionScopes = decisionScopeList, - timeout = 200 + timeoutSeconds = 0.2 ) }) { Text( diff --git a/code/testapp/src/main/java/com/adobe/marketing/optimizeapp/viewmodels/MainViewModel.kt b/code/testapp/src/main/java/com/adobe/marketing/optimizeapp/viewmodels/MainViewModel.kt index cb90705..2240944 100644 --- a/code/testapp/src/main/java/com/adobe/marketing/optimizeapp/viewmodels/MainViewModel.kt +++ b/code/testapp/src/main/java/com/adobe/marketing/optimizeapp/viewmodels/MainViewModel.kt @@ -71,9 +71,9 @@ class MainViewModel: ViewModel() { * Calls the Optimize SDK API to get the Propositions see [Optimize.getPropositions] * * @param [decisionScopes] a [List] of [DecisionScope] - * @param [timeout] a [Long] in milliseconds + * @param [timeoutSeconds] a [Double] in seconds */ - fun getPropositions(decisionScopes: List, timeout: Long? = null) { + fun getPropositions(decisionScopes: List, timeoutSeconds: Double? = null) { optimizePropositionStateMap.clear() val callback = object : AdobeCallbackWithError> { override fun call(propositions: Map?) { @@ -86,8 +86,8 @@ class MainViewModel: ViewModel() { print("Error in getting Propositions.") } } - timeout?.let { milliseconds -> - Optimize.getPropositions(decisionScopes, milliseconds, callback) + timeoutSeconds?.let { seconds -> + Optimize.getPropositions(decisionScopes, seconds, callback) } ?: Optimize.getPropositions(decisionScopes, callback) }