πŸ“… You're Invited: Meet the Socket team at RSAC (April 28 – May 1).RSVP β†’
Socket
Sign inDemoInstall
Socket

expo-notifications

Package Overview
Dependencies
Maintainers
28
Versions
195
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

expo-notifications

Provides an API to fetch push notification tokens and to present, schedule, receive, and respond to notifications.

0.31.1
latest
Source
npm
Version published
Weekly downloads
305K
-1.78%
Maintainers
28
Weekly downloads
Β 
Created

What is expo-notifications?

The expo-notifications package is a library for handling notifications in Expo and React Native applications. It provides tools for scheduling, receiving, and managing both local and push notifications.

What are expo-notifications's main functionalities?

Scheduling Local Notifications

This feature allows you to schedule local notifications to be triggered at a specific time or after a certain delay.

import * as Notifications from 'expo-notifications';

async function scheduleNotification() {
  await Notifications.scheduleNotificationAsync({
    content: {
      title: "You've got mail! πŸ“¬",
      body: 'Here is the notification body',
    },
    trigger: { seconds: 2 },
  });
}

Handling Received Notifications

This feature allows you to handle notifications when they are received, enabling you to perform actions or update the UI in response to the notification.

import * as Notifications from 'expo-notifications';
import { useEffect } from 'react';

useEffect(() => {
  const subscription = Notifications.addNotificationReceivedListener(notification => {
    console.log(notification);
  });
  return () => subscription.remove();
}, []);

Requesting Permissions

This feature allows you to request the necessary permissions from the user to send notifications.

import * as Notifications from 'expo-notifications';

async function requestPermissions() {
  const { status } = await Notifications.requestPermissionsAsync();
  if (status !== 'granted') {
    alert('Permission not granted!');
  }
}

Customizing Notification Behavior

This feature allows you to customize how notifications are handled when they are received, such as whether to show an alert, play a sound, or set a badge.

import * as Notifications from 'expo-notifications';

Notifications.setNotificationHandler({
  handleNotification: async () => ({
    shouldShowAlert: true,
    shouldPlaySound: false,
    shouldSetBadge: false,
  }),
});

Other packages similar to expo-notifications

Keywords

react-native

FAQs

Package last updated on 30 Apr 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts