Notification Feed API for Websites

Get a JSON of all your recently pushed campaigns to create a Notification Center! 🔔

This API allows you to get a list of recently published campaigns in a JSON format which can then be used to create a fully customizable Notification Center for your website. The design of the Notification Center including the UI/X would have to be thought through by you and your team. On a very high level, using this API would include the following steps:

  • Make sure News Hub is configured and enabled but the widget is not shown for your Website: Once News Hub is enabled for your website, you will have to make sure that the widget is not visible on the website to avoid duplicacy. Set showNewsHub to false while initiating the iZooto script.
<script> window._izq.push(["init",{'showNewsHubWidget':false}]); </script> 
///showNewsHubWidget is set to false

<script src="https://cdn.izooto.com/scripts/xxxxxxxxxxxxxxxxxx.js"></script> 
/// Replace this with your website specific JS Code.
  • Creating and designing the Notification Widget and Feed Menu: Be creative in your approach and lure users in by designing an attractive and useful Notification Center. Customize it with your website theme and run hypotheses/experiments to maximize engagement.

  • Populating the Feed Menu with data: We will talk about this step in detail in the below section.


Using the API

This API provides data in a succession of 10 notifications/call. You can call the API again to provide the next 10 results and so on.
To fetch the initial feed data (10 notifications) a developer needs to call a JavaScript method on a webpage as given below:

_izq.push(["getNotificationFeed", function(response) {
    //Do something with response
}]);

Note: This API should only be called after you've initialized the iZooto script for your page.

You will receive a response data which will have the following attributes:

Property NameData TypeDescription
SuccessBooleanTrue / False indicating whether the API call was a success or not.
ResponseStringReason of Success or Failure.
DataArrayNotification data - Array of objects
errorCode
(In case of failure only)
NumberWhere,
1 = No more notifications available
2 = Null: No notifications sent

👍

For an ideal UX, use Lazy Loading and show up more notifications as the user scrolls down your Notification Center.


Sample Request and Response Syntax

Sample Request

Sample code to call the API. In this example, we are printing the response in the console however in real-time you can store the response and use that to fill up your Notification Center.

_izq.push(["getNotificationFeed", function(response) {
    console.log (response)
}]);

Sample response (Success)

{
  success: true,
  response: "Notification feed fetched successfully"
  data: [
  {
  title: "IND vs PAK on 28th August 2022",
 	bannerImage: "",
  createdAt: "1645596480102",
  icon: "https://cdnimg.izooto.com/icons/7/bell-icon.png",
  landingUrl: "https://www.hotstar.com/in",
  message: "Watch Exclusive on Disney + Hotstar."
	},
	{
  title: "Pakistan Floods: Death Toll Touches 1,061, Prime Minister Shehbaz Calls Situation 'Horrifying’",
  bannerImage: "https://images.news18.com/ibnlive/uploads/2022/08/reuters-pakistan-floods-16617516643x2.png?impolicy=website&width=510&height=356",
  createdAt: "1645596480102",
  icon: "https://cdnimg.izooto.com/icons/7/bell-icon.png",
  landingUrl: "https://www.news18.com/news/world/pakistan-floods-death-toll-touches-1061-prime-minister-shehbaz-calls-situation-horrifying-5842999.html",
  message: "Both the Pakistan prime minister Shehbaz Sharif and the army chief Qamar Javed Bajwa spent the entire day amid flood victims”,
 	},
  .
  .
  .
  .
  .
  .
  .
  . // Upto 10 results in the data object.
	}]
}

Data Object Parameters

NameDescription
TitleThis is the Title used in the notification.
Banner ImageThe featured image is associated with the notification.
Created AtThe time at which this notification was sent from your iZooto Account.
IconThe icon is associated with the notification.
Landing URLThe URL to which the user was taken when we clicked on the notification.
MessageThe description used inside the notification.

Sample response (Failure): No More Notifications

In this case, a developer tried calling the API again and had already received all the notification data before. As a result, the API informed him that there were no more notifications available.
This response can be identified with the unique error code of 1.

{
  success: false
  errorCode: 1
  data: []
  response: "No more notifications available"
}

Sample response (Failure): Null Notifications

In this case, the user had not sent even 1 notification from his iZooto Account and hence received a null error. If the same API would be called after sending a notification, success would be returned.
This response can be identified with the unique error code of 2.

{
  success: false,
  errorCode: 2,
  data: [],
  response: "Null: No notifications sent"
}


👍

You're All Set 🚀

Get access to use this API. Reach out to us on [email protected] and we'd be happy to help.