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 undermentioned 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(inAppData (JSONObject));

For example,

const inAppData = {
      tokens: { name: "Ram" },
      customRules: { page: "dashborad" },
 };

 NotifyVisitors.show(inAppData);

๐Ÿ“˜

NOTE:

From plugin v2.0.5 onwards, the below implementation is recommended

NotifyVisitors.showInAppMessage({tokens: JSONObject, customRules: JSONObject}).then((value: any) => {});

For example,

const myUserToken = {"name" : "ravi", "age" : 49}; 
const myCustomRule = {"category" : "flowers"}; 

NotifyVisitors.showInAppMessage({tokens: myUserToken, customRules: myCustomRule}).then((value: any) => {
        //do your task here
});

Data in Callback (Type 1)

STATUS EVENT NAME MESSAGE TYPE CALLBACK TYPE
success Banner Impression InApp banner shown. 15.12, 15.13, 15.14, 15.17, 15.18 banner
Banner Clicked InApp Banner clicked. 15.0 to 15.11, 15.15, 15.16 banner
Survey Attempt Survey attempted successfully. 14.0, 14.2 survey
Survey Submit Survey submitted successfully. 14.1, 14.3 survey

Data in Callback2

status message type notificationsShown notificationsNotShown
success Found some active & inactive notifications. 19.1 [133,168] or [] [146] or []
fail No internet found 19.0
No 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
Something went wrong with error -> 19.6, 19.5, 19.2
No data found regarding any banner/survey 19.4

๐Ÿ“˜

NOTE:

  1. In the above Callback table, 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.
  2. As the extra callbacks are currently available on the Android platform only, it behaves identically to the show() function on the iOS platform, allowing you to avoid adding platform-specific checks when using this updated function.

DYNAMIC TOKENS (JSON Object)

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

const inAppData = {tokens:{"name":"neeraj"}, customRules:{"banerrType":"dashborad"}};
NotifyVisitors.show(inAppData);

//Example
 const inAppData = {
      tokens: { name: "neeraj" },
      customRules: { page: "dashborad" },
 };
 NotifyVisitors.show(inAppData);

CUSTOM RULES (JSON Object)

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

 const inAppData = {
      tokens: { name: "neeraj" },
      customRules: { page: "dashborad" },
 };
 NotifyVisitors.show(inAppData);

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.

Stop Notification

If a client wants to stop displaying inapp notifications (banners & surveys) then they can call this function in their app.

Notifyvisitors.stopNotification();