Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

expo-notifications

Package Overview
Dependencies
Maintainers
29
Versions
160
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.29.11
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
134K
decreased by-42.23%
Maintainers
29
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

FAQs

Package last updated on 05 Dec 2024

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc