Skip to content

Receive GetSocial Notifications using React Native

Notification Center with GetSocial

GetSocial provides a data API to implement notification center, similar to what Facebook has, inside your application. All notifications received via API will also generate an associated push notification.

GetSocial Notification Center UI

Let your users receive and interact with GetSocial Notifications in minutes, not days with prebuilt Notification Center UI.


Receive Notifications

To be sure your users didn’t miss any important (or not) notifications, you can query GetSocial notifications and show them to your user inside the app.


You have two types of queries: NotificationQuery and NotificationsCountQuery to get notifications list and notifications count respectively.

Notification can differ by a read status - be read or unread. Also each notification has type, it is one of Notification.Types constants.

To query notifications by status, use withStatus(status: [string]) factory method. You can pass one or few statuses, from Notification.Status constants. Use withAllStatus() to query notifications with any status.

By default notifications of all types are queries. To specify a list of types you’re interested in call method ofTypes(types: [string]) and pass one or few types you want to query.

Notifications Count

To get the count of notifications use GetSocialUser.getNotificationsCount(query) method. For example, to get a number of all unread notifications for current user:

const query = NotificationsCountQuery.withStatus([Notification.Status.UNREAD]);
GetSocialUser.getNotificationsCount(query).then((numberOfNotifications) => {
  console.log('Unread notifications count: ' + numberOfNotifications);
}, (error) => {
  console.log('Failed to get notifications count: ' + error);

Notifications List

Similar to notifications count you can fetch a list of notifications using GetSocialUser.getNotifications(query) method:

const query = NotificationsCountQuery.withStatus([Notification.Status.UNREAD]);
GetSocialUser.getNotifications(query).then((notifications) => {
}, (error) => {
  console.log('Failed to get notifications: ' + error);

Notifications Status

Read and Unread

All the notifications that are sent to a user are unread. The only exception is notifications that was clicked by a user - such becomes read automatically.

If you want to set notification read or unread use GetSocialUser.setNotificationsStatus(notificationIds, status) method:

const notificationsToBeRead: Array<Notification> = ...;
const notificationIds = => {
const newStatus = Notification.Status.READ;
GetSocial.User.setNotificationsStatus(notificationIds, newStatus).then(() => {
  console.log('Successfully changed notifications status');
}, (error) => {
  console.log('Failed to change notifications status: ' + error);

You can mark just one notification using [].

Consumed and Ignored

If your notification is kind of “consumable” - e.g. friend request, pending action or whatever it could be(check some possible usecase) - you may want to mark it as “consumed” by user, so it won’t appear in the list of read/unread notifications. For this there is Notification.Status.CONSUMED status. If user wants to ignore it, e.g. decline friends request, set it to Notification.Status.IGNORED.

Next Steps

Give us your feedback! Was this article helpful?

😀 🙁