--- title: Push Notifications Overview sidebar_title: Overview --- Push Notifications are an important feature, no matter what kind of app you're building. Not only is it nice to let users know about something that may interest them, be it a new album being released, a sale or other limited-time-only deal, or that one of their friends sent them a message, but push notifications are proven to help boost user interaction and create a better overall user experience. Whether you just want to be able to let users know when a relevant event happens, or you're trying to optimize customer engagement and retention, Expo makes implementing push notifications almost too easy. All the hassle with native device information and communicating with APNs (Apple Push Notification service) or FCM (Firebase Cloud Messaging) is taken care of behind the scenes, so that you can treat iOS and Android notifications the same, saving you time on the front-end, and back-end! There are three main steps to setting up push notifications, and we provide a guide for each part of the process: - [Setup: getting a user's Expo Push Token](push-notifications-setup.mdx) - [Sending: calling Expo's Push API with the token when you want to send a notification](sending-notifications.mdx) - [Receiving: responding to the notification in your app](receiving-notifications.mdx) (maybe upon opening, you want to jump to a particular screen that the notification refers to) ## Usage The code below shows a full example of how to register for, send, and receive push notifications in a React Native app. But make sure to read the rest of the guide, so that you understand how Expo's push notification service works, what the best practices are, and how to investigate any problems you run into! ```js import * as Device from 'expo-device'; import * as Notifications from 'expo-notifications'; import React, { useState, useEffect, useRef } from 'react'; import { Text, View, Button, Platform } from 'react-native'; Notifications.setNotificationHandler({ handleNotification: async () => ({ shouldShowAlert: true, shouldPlaySound: false, shouldSetBadge: false, }), }); export default function App() { const [expoPushToken, setExpoPushToken] = useState(''); const [notification, setNotification] = useState(false); const notificationListener = useRef(); const responseListener = useRef(); useEffect(() => { registerForPushNotificationsAsync().then(token => setExpoPushToken(token)); // This listener is fired whenever a notification is received while the app is foregrounded notificationListener.current = Notifications.addNotificationReceivedListener(notification => { setNotification(notification); }); // This listener is fired whenever a user taps on or interacts with a notification (works when app is foregrounded, backgrounded, or killed) responseListener.current = Notifications.addNotificationResponseReceivedListener(response => { console.log(response); }); return () => { Notifications.removeNotificationSubscription(notificationListener.current); Notifications.removeNotificationSubscription(responseListener.current); }; }, []); return ( Your expo push token: {expoPushToken} Title: {notification && notification.request.content.title} Body: {notification && notification.request.content.body} Data: {notification && JSON.stringify(notification.request.content.data)}