ElimE
Convex Community8mo ago
2 replies
Elim

@convex/expo-push-notifications sending notification to all registered tokens

Hi, in my app I want to send notification to all users that have registered for push notifications.
I noticed that there is a table 'pushTokens' table under pushNotifications component in the dashboard. I want to query this table from my mutation instead of querying all 'users', but I cant find any documentation for this.

Also, is it safe to call pushNotifications.sendPushNotification() like this for every registered token?
await Promise.all(
      registeredTokens.map(async ({ userId }) => {
        await pushNotifications.sendPushNotification(ctx, {
          userId,
          notification: {
            title: 'New post!',
            body: 'Check out what's happening!',
          },
        });
      })
    );

Does this component mind expo's send request and other limits? Documentation on this is very poor...
Was this page helpful?