Recommendation API
Nuance Messaging SDK enables targetting by providing a rules engine within the SDK.
Recommendation API works in conjunction With Data Collection API, Data Collection startSession API should have invoked by the Application prior to requesting recommendation from the SDK.
Public methods
Following methods are exposed from NuanMessaging class.
-
public void getRecommendation(String eventName, HashMap<String,Object> eventData)
Invoking this method will trigger Business Rule execution.
eventName: Name of the event that just happened in the Application.
eventData: Data associated with this event. Business Rules will use this data to determining a recommendation.
-
public void setRecommendationListener(RecommendationListener listener)
Application must set a listener to receive recommendation.
-
public Boolean isBRReady()
Use this method to check if Business Rules are downloaded and ready to execute.
-
public void whenBRReadyListener(OnSuccessListener
listener) In case if Business Rules are not yet ready, pass a listener to this function which will be fired upon ready
RecommendationListener
RecommendationListener.onRecommendation is fired upon successfull matching of a rule condition.
NuanMessaging.getInstance().setRecommendationListener(new RecommendationListener() {
@Override
public void onRecommendation(RecommendationResponse response) {
System.out.println("recommendation:"+response);
}
});
Button b2 = (Button) findViewById(R.id.button2);
b2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
HashMap event = new HashMap();
event.put("pageMarker","sale");
NuanMessaging.getInstance().getRecommendation("onAnyEvent",event);
}
});
NuanMessaging.getInstance().setRecommendationListener(new RecommendationListener() {
@Override
public void onRecommendation(RecommendationResponse response) {
System.out.println("recommendation:"+response);
}
});
Button b2 = (Button) findViewById(R.id.button2);
b2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
HashMap event = new HashMap();
event.put("pageMarker","sale");
NuanMessaging.getInstance().getRecommendation("onAnyEvent",event);
}
});