@spacehq/sdk > UserStorage > notificationSubscribe
UserStorage.notificationSubscribe() method
NotificationSubscribe is used to listen for Mailbox events.
It listens to the users mailbox events, enriches the message with Space specific data.
Signature:
notificationSubscribe(): Promise<NotificationSubscribeResponse>;
Returns:
Promise<NotificationSubscribeResponse>
Example
const spaceStorage = new UserStorage(spaceUser);
await spaceStorage.initListener();
const response = await spaceStorage.notificationSubscribe();
response.on('data', (data: NotificationSubscribeEvent) => {
const { notification: { relatedObject } } = data as Notification;
console.log('file invitation: ', relatedObject);
});