Recommendation API
Nuance Messaging SDK enables targeting by providing a rules engine within the SDK.
Recommendation API works in conjunction With Data Collection API, Data Collection startSession API must be invoked by the Application prior to requesting recommendation from the SDK.
Public Methods
Following methods are exposed from NuanMessaging class.
-
-(void) getRecommendation:(NSString*)eventName andEventData:(NSDictionary
*)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.
-
-(void) setRecommendationListener:(void (^)(RecommendationResponse* recommendation))completionBlock;
Application must set a listener to receive recommendation.
-
- (BOOL)isBRReady
Use this method to check if Business Rules are downloaded and ready to execute.
-
-(void)setBRReadyListener:(void (^)(Response* success, Response *error))completionBlock;
In case if Business Rules are not yet ready, pass a listener to this function which will be fired upon ready
if(!(nuanMessaging?.isBRReady())!) {
nuanMessaging?.setBRReadyListener({ (resp, error) in
nuanMessaging?.isBRReady()
var dictionary: [String:Any] = [
"1" : 1,
"sale" : "hello",
"three" : 3
]
nuanMessaging?.getRecommendation("test", andEventData: dictionary)
})
} else {
print((nuanMessaging?.isBRReady())!)
}