Code Reference

Notifications

React Native · Reference cheat sheet

Notifications

React Native · Reference cheat sheet


📋 Overview

Local and push notifications alert users outside the app UI. On Expo, use expo-notifications; bare RN often uses Firebase / Notifee.

🔧 Core concepts

PieceRole
PermissionsRequest before scheduling
LocalScheduled on-device
PushRemote via FCM/APNs
HandlersForeground / response listeners

💡 Examples

import * as Notifications from 'expo-notifications';

Notifications.setNotificationHandler({
  handleNotification: async () => ({
    shouldShowAlert: true,
    shouldPlaySound: false,
    shouldSetBadge: false,
    shouldShowBanner: true,
    shouldShowList: true,
  }),
});
await Notifications.scheduleNotificationAsync({
  content: { title: 'Reminder', body: 'Ship the docs' },
  trigger: { type: Notifications.SchedulableTriggerInputTypes.TIME_INTERVAL, seconds: 5 },
});

⚠️ Pitfalls

  • iOS requires explicit permission; Android 13+ needs POST_NOTIFICATIONS.
  • Don’t assume push tokens are stable forever.
  • Handle notification taps to deep-link into the right screen.

On this page