In-app Notifications
Configure target rules for in-app notifications.
In-app Messaging includes both Banners and Surveys. They are displayed on the basis of user activities on android.
Every event occurs in the context of an Activity. Every activity can be associated with some contextual data, which can be used as targeting rules for In-app Messaging.
Use the below show() Method for every activity. show() Method should be used only once as per the activity.
NotifyVisitorsApi.getInstance(activityContext).show(JSONObject dynamicTokens, JSONObject customRules, String fragmentName);
NotifyVisitorsApi.getInstance(activityContext).show(JSONObject dynamicTokens, JSONObject customRules, String fragmentName)
Show() method has three attributes:
- Dynamic Tokens (JsonObject)
- Custom Rules (JsonObject)
- Fragment Name (String)
DYNAMIC TOKENS (JSON Object)
Dynamic tokens are used to show personalized content in Notification messages in real time.
JSONObject tokens = new JSONObject();
try {
tokens.put("Budget", "CAD $300,000 to $600,000");
tokens.put("ProjectName", "| New Development | Kings Landing Condos |");
} catch (JSONException e) {
e.printStackTrace();
}
val tokens = JSONObject()
try {
tokens.put("Budget", "CAD $300,000 to $600,000")
tokens.put("ProjectName", "| New Development | Kings Landing Condos |")
} catch (e: JSONException) {
e.printStackTrace()
}
CUSTOM RULES (JSON Object)
This data can be used in configuring targeting rules for the Notifications.
JSONObject customObj = new JSONObject();
try {
customObj.put("test","abc");
customObj.put("PAGE_ID", "DASHBOARD");
} catch (JSONException e) {
e.printStackTrace();
}
val customObj = JSONObject()
try {
customObj.put("test","abc")
customObj.put("PAGE_ID", "DASHBOARD")
} catch (e: JSONException) {
e.printStackTrace()
}
FRAGMENT NAME (string)
If you have multiple fragment tabs in your activity, you can use the show method for each fragment and pass the fragment name as the third argument.
In-app Notifications Response Callback
If you want to get callback data whenever user clicks on in-app banners or fill-up surveys.
NotifyVisitorsApi.getInstance(activityContext).getEventResponse(new OnEventTrackListener() {
@Override
public void onResponse(JSONObject jsonObject) {
//do your task here
}
});
NotifyVisitorsApi.getInstance(activityContext).getEventResponse(object : OnEventTrackListener {
override fun onResponse(p0: JSONObject?) {
//do your task here
}
})
Updated 3 months ago