In-App Notification

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. The show() method should be used only once as per the activity. You can pass an optional callback function as the last parameter if you want to get responses from banners and survey clicks.

Notifyvisitors.show((JSONObject)tokens, (JSONObject)customObjects, (String)fragmentName, callback);

For example,

Notifyvisitors.show(null,null,null, function(callback){
     //do your task here
});

You will get the following callback data whenever the user clicks on in-app banners or fill-up surveys.

This callback will provide you output in JSON format. Sample output is shared below-

{
   "status":"success",
   "eventName":"Survey Submit",
   "message":"Survey submitted successfully.",
   "type":14.3,
   "callbackType":"survey"
}

In the above output, the parameters have different values depending on the scenario that occurs when displaying banners or surveys. Below are the different values you can get in the callback:

STATUSEVENT NAMEMESSAGETYPECALLBACK TYPE
SuccessBanner ClickedInApp banner clicked.Banner
SuccessBanner ImpressionInApp banner shown.Banner
SuccessSurvey AttemptSurvey attempted successfullySurvey
SuccessSurvey SubmitSurvey submitted successfullySurvey

📘

NOTE:

-> In above function third parameter(i.e., fragmentName) will always be null
-> The above function has been deprecated plugin v^4.4.2 onwards instead you can implement the below function

Notifyvisitors.showInAppMessage((JSONObject)tokens, (JSONObject)customObjects, (String)fragmentName, callback); 

For example,

Notifyvisitors.showInAppMessage(null, null, null, function(callback: any) {
         //do your work here
});  

Callback Response

In showInAppMessage function you will get 2 types of callback. Both examples are shared below.

{
   “status”:“success”,
   “message”:“Found some active & inactive notifications.”,
   “type”:19.1,
   “notificationsShown”:[
      
   ],
   “notificationsNotShown”:[
      “4185”
   ]
}

In the above response, the STATUS field represents whether the banner/survey data was processed successfully or not, the MESSAGE field represents details of why the status failed and, the TYPE field is used for the SDK internal process. All other responses are mentioned in the table below.

statusmessagetypenotificationsShownnotificationsNotShown
successFound some active & inactive notifications.19.1[133,168] or [][146] or []
failNo internet found19.0
failNo banner|survey is active. If active on NV dashboard then kindly check DEBUG|LIVE mode of your app and mode in NV dashboard for active notifications.19.3
failSomething went wrong with error -> 19.6, 19.5, 19.2
failNo data found regarding any banner/survey19.4

AND

{
   "status":"success",
   "eventName":"Survey Submit",
   "message":"Survey submitted successfully.",
   "type":14.3,
   "callbackType":"survey"
}

In the above output, the parameters have different values depending on the scenario that occurs when displaying banners or surveys. Below are the different values you can get in the callback:

STATUSEVENT NAMEMESSAGETYPECALLBACK TYPE
SuccessBanner ClickedInApp banner clicked.15.0 to 15.11, 15.15, 15.16Banner
SuccessBanner ImpressionInApp banner shown.15.12, 15.13, 15.14, 15.17, 15.18Banner
SuccessSurvey AttemptSurvey attempted successfully.14.0, 14.2Survey
SuccessSurvey SubmitSurvey submitted successfully.14.1, 14.3Survey

DYNAMIC TOKENS (JSON Object)

Dynamic tokens are used to show personalized content in Notification messages in real-time.

var customRules = { "category" : "flowers" };
var dynamicTokens = { "name" : "ravi", "age" : 49 };

Notifyvisitors.show(dynamicTokens, customRules, null);

CUSTOM RULES (JSON Object)

This data can be used in configuring targeting rules for the Notifications.

var customRules = { "category" : "flowers" };
var dynamicTokens = { "name" : "ravi", "age" : 49 };

notifyvisitors.show(dynamicTokens, customRules, null);

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.