npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

react-native-nitro-notification

v0.1.0

Published

Remote push notifications (APNs) via Nitro Modules

Readme

react-native-nitro-notification

Work in progress. This library is under active development, the API will likely change, and it is not ready for production use.

A thin, fast, type-safe wrapper around Apple Push Notification service (APNs) for React Native, built on Nitro Modules.

This library is for remote push notifications only — notifications sent from a server to a device via APNs. It is not for local (in-app scheduled) notifications. It handles:

  • Requesting and checking notification permissions
  • Registering with APNs to get a device token you send to your server
  • Receiving notifications while the app is in the foreground
  • Handling notification taps (foreground and background)
  • Controlling how notifications appear when the app is open

Your backend is responsible for sending the actual push via APNs or a provider like Firebase FCM, OneSignal, or Expo Push.

iOS only for now. Android support is not yet planned.

Requirements

  • React Native 0.76+
  • New Architecture enabled
  • react-native-nitro-modules installed

Installation

yarn add react-native-nitro-notification react-native-nitro-modules

Then install pods:

cd ios && pod install

iOS Setup

The library needs to receive the device push token from the system. iOS delivers this exclusively through two AppDelegate methods that you must forward manually.

Open your AppDelegate.swift and add the following:

import react_native_nitro_notification

// Inside your AppDelegate class:

func application(
  _ application: UIApplication,
  didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data
) {
  NotificationCenter.default.post(
    name: NitroNotificationTokenNotification,
    object: nil,
    userInfo: [NitroNotificationTokenKey: deviceToken]
  )
}

func application(
  _ application: UIApplication,
  didFailToRegisterForRemoteNotificationsWithError error: Error
) {
  // handle or ignore
}

These two methods are the only way iOS delivers push tokens to an app. There is no alternative hook. The library re-exports NitroNotificationTokenNotification and NitroNotificationTokenKey so you don't have to hardcode any strings.


Capabilities

In Xcode, go to your target > Signing & Capabilities and add Push Notifications.Background Modes (optional) — only needed if you want your app to wake up in the background to silently process a notification before the user taps it (requires content-available: 1 in the APNs payload). Not needed for standard foreground/tap notification handling.


Usage

import { Notifications } from 'react-native-nitro-notification';

Request permissions

Must be called before any notification can be delivered. Prompts the user on first call.

const status = await Notifications.requestPermissions();
// 'granted' | 'denied' | 'undetermined'

Get current permission status

Checks the current authorization state without prompting the user.

const status = await Notifications.getPermissionStatus();
// 'granted' | 'denied' | 'undetermined'

Get the device push token

Returns the APNs device token as a hex string. Resolves once the token is available — call requestPermissions() first so the system registers the device.

const token = await Notifications.getDevicePushToken();
// e.g. 'a1b2c3d4e5f6...'

Listen for token refreshes

APNs tokens can change. Register a listener to always have the latest one.

Notifications.setOnTokenRefreshed((token) => {
  // send token to your server
});

Unregister from notifications

Stops receiving remote notifications and invalidates the push token.

await Notifications.unregisterForNotifications();

Handle foreground notifications

Fired when a notification arrives while the app is in the foreground.

Notifications.setOnNotificationReceived((notification) => {
  console.log(notification.title);
  console.log(notification.body);
  console.log(notification.data); // Record<string, string> | undefined
  console.log(notification.badge); // number | undefined
});

Handle notification taps

Fired when the user taps a notification (foreground or background).

Notifications.setOnNotificationTapped((response) => {
  console.log(response.actionIdentifier); // e.g. 'com.apple.UNNotificationDefaultActionIdentifier'
  console.log(response.notification.title);
});

Control foreground presentation

By default all three options are enabled. Call this to customize how notifications appear when the app is in the foreground.

Notifications.setForegroundPresentationOptions({
  alert: true, // banner
  badge: true,
  sound: true,
});

Types

type PermissionStatus = 'granted' | 'denied' | 'undetermined';

interface NotificationPayload {
  title: string | undefined;
  body: string | undefined;
  data: Record<string, string> | undefined;
  badge: number | undefined;
}

interface NotificationResponse {
  notification: NotificationPayload;
  actionIdentifier: string;
}

interface ForegroundPresentationOptions {
  alert: boolean;
  badge: boolean;
  sound: boolean;
}

Full example

import { useEffect } from 'react';
import { Notifications } from 'react-native-nitro-notification';

const setupNotifications = async () => {
  const status = await Notifications.requestPermissions();
  if (status !== 'granted') return;

  const token = await Notifications.getDevicePushToken();
  await sendTokenToServer(token);

  Notifications.setOnTokenRefreshed(async (newToken) => {
    await sendTokenToServer(newToken);
  });

  Notifications.setForegroundPresentationOptions({
    alert: true,
    badge: false,
    sound: true,
  });

  Notifications.setOnNotificationReceived((notification) => {
    console.log('Received:', notification.title);
  });

  Notifications.setOnNotificationTapped((response) => {
    console.log('Tapped:', response.notification.title);
  });
};

useEffect(() => {
  setupNotifications();
}, []);

License

MIT