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-ideo-pns

v0.0.20

Published

Ideo digital push notifications library

Downloads

42

Readme

🚀 React Native Push Notifications

This module provides an Apple & Android Push Notification Service integration.
It allows:

  • Requesting notification permissions 📩
  • Retrieving the APNs device token 🔑
  • Listening for APNs token updates 📡
  • Checking the current notification permission status
  • Handling background notification launches 📲

📌 Installation and Setup

npm install react-native-ideo-pns

IOS

1️⃣ Enable Remote Notifications in Xcode

  1. Open Xcode (ios/YourApp.xcworkspace).
  2. Go to Signing & Capabilities > Background Modes.
  3. Enable "Remote notifications".
  4. Add the Push Notifications capability in Signing & Capabilities.

2️⃣ Modify AppDelegate.m to Handle APNs Events

Since APNs registration is handled in AppDelegate.m, we must forward events to the Turbo Module (IdeoPns).

📍 Add the Following Code to ios/AppDelegate.m

#import "AppDelegate.h"
#import <UserNotifications/UserNotifications.h>
#import <React/RCTBridge.h>
#import <React/RCTEventEmitter.h>

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    ...
    UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
    center.delegate = self; // Ensures push notifications can be received

    NSDictionary *remoteNotification = launchOptions[UIApplicationLaunchOptionsRemoteNotificationKey];

    if (remoteNotification) {
        // Store the notification in NSUserDefaults to be processed when the module is ready
        [[NSUserDefaults standardUserDefaults] setObject:remoteNotification forKey:@"PENDING_NOTIFICATION"];
        [[NSUserDefaults standardUserDefaults] synchronize];
    }
    ...
}

// ✅ Handle Notification Clicks
- (void)userNotificationCenter:(UNUserNotificationCenter *)center
    didReceiveNotificationResponse:(UNNotificationResponse *)response
         withCompletionHandler:(void (^)(void))completionHandler
{
    NSDictionary *userInfo = response.notification.request.content.userInfo;
    [[NSNotificationCenter defaultCenter] postNotificationName:@"NotificationOpened" object:userInfo];
    completionHandler();
}

// ✅ Handle Foreground Notifications
- (void)userNotificationCenter:(UNUserNotificationCenter *)center
       willPresentNotification:(UNNotification *)notification
         withCompletionHandler:(void (^)(UNNotificationPresentationOptions options))completionHandler
{
    NSDictionary *userInfo = notification.request.content.userInfo;
    [[NSNotificationCenter defaultCenter] postNotificationName:@"NotificationReceived" object:userInfo];
    completionHandler(UNNotificationPresentationOptionAlert | UNNotificationPresentationOptionSound);
}

// ✅ Forward APNs Device Token to `IdeoPns`
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
{
    NSMutableString *tokenString = [NSMutableString string];
    const unsigned char *bytes = (const unsigned char *)[deviceToken bytes];
    for (NSUInteger i = 0; i < [deviceToken length]; i++) {
        [tokenString appendFormat:@"%02x", bytes[i]];
    }

    NSLog(@"🔥 APNs Device Token: %@", tokenString);

    // Store token persistently
    [[NSUserDefaults standardUserDefaults] setObject:tokenString forKey:@"APNsIdeoPns"];
    [[NSUserDefaults standardUserDefaults] synchronize];

    // 🔥 Send token to IdeoPns via NotificationCenter
    [[NSNotificationCenter defaultCenter] postNotificationName:@"APNsIdeoPnsReceived" object:tokenString];
}

// ✅ Forward Failure to `IdeoPns`
- (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error
{
    NSLog(@"❌ Failed to register for remote notifications: %@", error.localizedDescription);
    [[NSNotificationCenter defaultCenter] postNotificationName:@"APNsRegistrationFailed" object:error.localizedDescription];
}

@end

2️⃣ Modify AppDelegate.h to Handle APNs Events

#import <RCTAppDelegate.h>
#import <UIKit/UIKit.h>
#import <UserNotifications/UserNotifications.h>

@interface AppDelegate : RCTAppDelegate <UNUserNotificationCenterDelegate>

@end

Android

1️⃣ Add to app/build.gradle

dependencies {
  // ... existing dependencies ...
  implementation project(':react-native-ideo-pns')
}

2️⃣ Update MainActivity.java/kt

package com.ideonotifications

import android.content.Intent
import android.os.Bundle
import com.facebook.react.ReactActivity
import com.facebook.react.ReactActivityDelegate
import com.ideopns.NotificationHandler

class MainActivity : ReactActivity() {
    // ... existing code ...
    
    override fun onNewIntent(intent: Intent) {
        super.onNewIntent(intent)        
        NotificationHandler.processIntent(intent)
    }
}

3️⃣ Update MainApplication.java/kt

package com.ideonotifications

import android.app.Application
import com.facebook.react.PackageList
import com.facebook.react.ReactApplication
import com.facebook.soloader.SoLoader
import com.ideopns.IdeoPnsModule

class MainApplication : Application(), ReactApplication {
    // ... existing code ...
    
    override fun onCreate() {
         // ... existing code ...
        // Initialize the IdeoPNS library
        IdeoPnsModule.initialize(this)
    }
}

🧩 Usage

import {
  getDeviceToken,
  requestPermissions,
  onNotificationOpened,
  onNotificationReceived,
  checkNotificationPermission,
  configure
} from 'react-native-ideo-pns';

async function setupNotifications() {
  try {
    console.log('🔄 Starting notification setup...');

    // 1️⃣ Request Notification Permissions
    const granted = await requestPermissions();
    console.log(
      granted ? '✅ Notifications Allowed' : '❌ Notifications Denied'
    );

    // 2️⃣ Check Current Notification Permission Status
    const permissions = await checkNotificationPermission();
    console.log('🔎 Current Notification Permissions:', permissions);

    // 3️⃣ Fetch APNs Device Token
    const token = await getDeviceToken();
    const apiKey = process.env.API_KEY;

    if (token && apiKey) {
      console.log('🔥 Device Token:', token);
      Platform.OS === 'android' && configure(token, apiKey);
      // Send token to your backend server here
    } else {
      console.log('⏳ No Token Available Yet...');
    }
    
    // 4️⃣ Listen for notification events
    const notificationOpenedListener = onNotificationOpened((notification) => {
      console.log('🔔 Notification opened:', notification);
      // Handle notification tap here
    });
    
    const notificationReceivedListener = onNotificationReceived((notification) => {
      console.log('📬 Notification received in foreground:', notification);
      // Handle foreground notification here
    });
    
    // Remember to remove listeners when component unmounts
    return () => {
      notificationOpenedListener.remove();
      notificationReceivedListener.remove();
    };
    
  } catch (error) {
    console.error('❌ Error in setupNotifications:', error);
  }
}

// 🚀 Call the function to initialize notifications
useEffect(() => {
  const cleanup = setupNotifications();
  
  return () => {
    if (cleanup) cleanup();
  };
}, []);

🔍 How it Works

The library handles these key scenarios:

  1. App Cold Launch from Notification: When user taps a notification that launches the app from a closed state
  2. Background/Foreground Notification Tap: When user taps a notification while app is already running
  3. Foreground Notification Reception: When a notification arrives while app is in active use

Implementation Details

  • iOS: Uses NSNotificationCenter and NSUserDefaults to handle notification events and pending notifications
  • Android: Uses NotificationHandler to process intents from notification interactions

📋 Troubleshooting

  • Ensure you've added all required capabilities in Xcode for iOS
  • For Android, verify the correct package names in imports
  • Check that you're properly removing event listeners when components unmount
  • Enable debug logging to trace notification flow

📚 API Reference

requestPermissions()

Request notification permissions from the user.

  • Returns: Promise<boolean> - Whether permissions were granted

getDeviceToken()

Get the current device token for push notifications.

  • Returns: Promise<string|null> - The token string or null if unavailable

checkNotificationPermission()

Check the current notification permission status.

  • Returns: Promise<PermissionStatus> - Current permission status

onNotificationOpened(callback)

Listen for when a notification is opened by user tap.

  • Parameters: callback(notification: object) => void
  • Returns: Subscription - Call .remove() to unsubscribe

onNotificationReceived(callback)

Listen for when a notification is received while app is in foreground.

  • Parameters: callback(notification: object) => void
  • Returns: Subscription - Call .remove() to unsubscribe