Skip to content

Latest commit

 

History

History
95 lines (64 loc) · 3.45 KB

File metadata and controls

95 lines (64 loc) · 3.45 KB

Prefetch Offer Content in Android

Adobe Target prefetch feature uses the Adobe Experience Cloud Platform SDKs to fetch offer content as few times as possible by caching the server responses.

This process reduces the load time, prevents multiple network calls, and allows Adobe Target to be notified which mbox was visited by the mobile app user. All content will be retrieved and cached during the prefetch call, and this content will be retrieved from the cache for all future calls that contain cached content for the specified mbox name.

Prefetch content does not persist across launches. The prefetch content is cached as long as the application lives or until the clearPrefetchCache() method is called.

TargetPrefetch Builder

TargetPrefetch builder helps to create a TargetPrefetch instance with the specified data. The returned instance can be used with prefetchContent, which accepts a TargetPrefetch object list to prefetch offers for the specified mbox locations.

Syntax

TargetPrefetch prefetchRequest = new TargetPrefetch.Builder("mboxName")
                .setMboxParameters(new HashMap<String, String>())
                .setOrderParameters(new HashMap<String, Object>())
                .setProductParameters(new HashMap<String, String>())
                .build();

prefetchContent

Sends a prefetch request to your configured Target server with the TargetPrefetch list and specified profileParameters. The callback will be invoked when the prefetch is complete, which returns a success status for the prefetch request.

Syntax

public static void prefetchContent(final List<TargetPrefetch>                                                                         targetPrefetchList,
                                    final Map<String, Object> profileParameters,
                                    final AdobeCallback<Boolean> callback);

Example

// first prefetch request
Map<String, Object> mboxParameters1 = new HashMap<>();
mboxParameters1.put("status", "platinum");

// second prefetch request
Map<String, Object> mboxParameters2 = new HashMap<>();
mboxParameters2.put("userType", "paid");

List<String> purchasedIds = new ArrayList<String>();
purchasedIds.add("34");
purchasedIds.add("125"); 

Map<String, Object> orderParameters2 = new HashMap<>();
orderParameters2.put("id", "ADCKKIM");
orderParameters2.put("total", "344.30");
orderParameters2.put("purchasedProductIds",  purchasedIds);

Map<String, Object> productParameters2 = new HashMap<>();
productParameters2.put("id", "24D3412");
productParameters2.put("categoryId","Books");

TargetPrefetch prefetchRequest1 = new TargetPrefetch.Builder("mboxName1")
                .setMboxParameters(mboxParameters1)
                .build();


TargetPrefetch prefetchRequest2 = new TargetPrefetch.Builder("mboxName2")
                .setMboxParameters(mboxParameters2)
                .setOrderParameters(orderParameters2)
                .setProductParameters(productParameters2)
                .build();


List<TargetPrefetchObject> prefetchMboxesList = new ArrayList<>();
prefetchMboxesList.add(prefetchRequest1);
prefetchMboxesList.add(prefetchRequest2);


// Call the prefetchContent API.
Target.prefetchContent(prefetchMboxesList, profileParameters, prefetchStatusCallback);

clearPrefetchCache

Clears the data that was cached by Target Prefetch.

Syntax

public static void clearPrefetchCache()

Example

Target.clearPrefetchCache();