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.
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:
const response = await exh.notificationsV2.findByTargetUserId(userId);
console.log('Notifications:', response.data);
Last updated