Skip to main content

executeNotification

Executes a notification action through the notifications guard function. Currently supports fetching notifications for the authenticated user.
action
'fetchByUserId'
required
The action to perform. Currently only “fetchByUserId” is supported.
Returns: Promise<Execution> Error Handling: Throws error if execution fails or status is “failed”. Error is logged and re-thrown.
import { executeNotification } from '@/services/notifications.service';

// Fetch notifications for the current user
const execution = await executeNotification({
  action: 'fetchByUserId'
});

// Parse the response
const notifications = JSON.parse(execution.responseBody);

// Display notifications
notifications.forEach(notification => {
  console.log(notification.message);
});

executePushToken

Manages push notification tokens for the current user. Allows registering new device tokens or removing them.
action
'send' | 'delete'
required
The action to perform on the push token
pushToken
string
required
The Expo push notification token to register or remove
Returns: Promise<Execution> Error Handling: Throws error if execution fails. Error is logged and re-thrown.
import { executePushToken } from '@/services/pushToken.service';
import * as Notifications from 'expo-notifications';

// Register a push token when user logs in
async function registerPushToken() {
  const token = await Notifications.getExpoPushTokenAsync();
  
  await executePushToken({
    action: 'send',
    pushToken: token.data
  });
}

// Remove push token when user logs out
async function removePushToken() {
  const token = await Notifications.getExpoPushTokenAsync();
  
  await executePushToken({
    action: 'delete',
    pushToken: token.data
  });
}
Push tokens are stored per user and used to send push notifications for likes, comments, and room activity. Multiple tokens can be registered for users who are logged in on multiple devices.
Always remove push tokens when a user logs out to prevent notifications being sent to devices that are no longer authenticated.

Build docs developers (and LLMs) love