Notifications

Create a notification

Notifications are created for individual users, a notification will be sent as a push notification to each of the user's registered devices.

circle-info

If the user doesn't have configured any devices, the notification will still be created but not marked as sent.

The Extra Horizon SDK can be used to create a notification as follows:

const notification = await exh.notificationsV2.create({
  targetUserId: userId,
  title: 'Hello from Extra Horizon',
  descriptions: 'Welcome to our platform'
});

console.log('Notification was created with id:', notification.id);
console.log('Notification was sent to a device:', notification.sent);

List notifications

There are multiple methods available in the SDK at exh.notificationsV2 to fetch notifications.

For example, getting a specific notification by its id:

const notification = await exh.notificationsV2.findById(notificationId);
console.log('Notification was sent to:', notification.targetUserId);

Or, list notifications for a specific user:

Last updated