Skip to main content
RichRelevance

Usage Example

The following is a very brief example that demonstrates basic SDK usage.

The first block is the initialization logic, and the second block is the request logic.

In Application.onCreate():

// First create a configuration and use it to configure the default client.

ClientConfiguration config = new ClientConfiguration("showcaseparent", "bccfa17d092268c0");
config.setApiClientSecret("r5j50mlag06593401nd4kt734i");
config.setUserId("RZTestUserTest");
config.setSessionId(UUID.randomUUID().toString());

RichRelevance.init(this, config);

// Enable all logging
RichRelevance.setLoggingLevel(RRLog.VERBOSE);

 

In an Activity or view logic:

// Create a "RecommendationsForPlacements" builder for the "add to cart" placement type.
Placement placement = new Placement(Placement.PlacementType.ADD_TO_CART, "prod1");
RichRelevance.buildRecommendationsForPlacements(placement)
       // Attach a callback
       .setCallback(new Callback<PlacementResponseInfo>() {
           @Override
           public void onResult(PlacementResponseInfo result) {
               PlacementResponse placement = result.getPlacements().get(0);
               RecommendedProduct product = placement.getRecommendedProducts().get(0);

               product.trackClick();
           }

           @Override
           public void onError(Error error) {
               Log.e(getClass().getSimpleName(), "Error: " + error.getMessage());
           }
       })

       // Execute the request
       .execute(); 
  • Was this article helpful?