Skip to main content

Push Notifications

The kit includes Expo push notifications.

Key File

lib/notifications.ts

Request Permission

import { requestNotificationPermission } from '@/lib/notifications';

const token = await requestNotificationPermission();

Send from Server

await fetch('https://exp.host/--/api/v2/push/send', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({
    to: 'ExponentPushToken[xxx]',
    title: 'Hello!',
    body: 'This is a notification',
  }),
});

Local Notifications

import * as Notifications from 'expo-notifications';

await Notifications.scheduleNotificationAsync({
  content: { title: 'Reminder', body: 'Check the app!' },
  trigger: { seconds: 3600 },
});

Testing

Use expo.dev/notifications to test.