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

rns-nativecall

v1.1.0

Published

High-performance React Native module for handling native VoIP call UI on Android and iOS.

Readme

rns-nativecall

A professional VoIP incoming call handler for React Native. Features a "Single Call Gate" on Android to manage busy states and full CallKit integration for iOS.

🚀 Highlights

  • Expo Support: Built-in config plugin handles all native setup.
  • Single Call Gate: Automatically detects if the user is in a call and flags secondary calls as "BUSY".
  • Headless Mode: Works even when the app is killed or the screen is locked.

📦 Installation

npx expo install rns-nativecall expo-build-properties

or

npm install rns-nativecall expo-build-properties

Add the plugin to your app.json or app.config.js:

{
  "expo": {
    "plugins": [
      [
        "expo-build-properties",
        {
          "android": {
            "enableProguardInReleaseBuilds": true,
            "extraProguardRules": "-keep class com.rnsnativecall.** { *; }\n-keep class com.facebook.react.HeadlessJsTaskService { *; }"
          }
        },
        "rns-nativecall"
      ]
    ]
  }
}

🛠 Usage

  1. Initialize Headless Task (index.js) Register the task at the very top of your entry file. This handles background calls and "Busy" signals for secondary callers.
import { AppRegistry } from 'react-native';
import App from './App';
import { CallHandler } from 'rns-nativecall';

CallHandler.registerHeadlessTask(async (data, eventType) => {
    if (eventType === 'BUSY') {
        // User is already on a call. Notify the second caller via WebSocket/API.
        console.log("System Busy for UUID:", data.callUuid);
        return;
    }

    if (eventType === 'INCOMING_CALL') {
        // App is waking up for a new call. 
        // Trigger your custom UI or logic here.
    }
});

AppRegistry.registerComponent('main', () => App);

Handling Events (Index.js)

// Index.js Setup Foreground Listeners
CallHandler.subscribe(

    async (data) => {
        try {
            console.log("APP IS OPEN", data)
           // navigate here
        } catch (error) {
            console.log("pending_call_uuid", error)
        }
    },

    async (data) => {
        try {
            console.log("CALL DECLINE", data)
           // update the caller here call decline
        } catch (error) {
            console.log("Onreject/ cancel call error", error)
        }
    },

    (data) => { console.log("failded", data) }
);

Handling Events (App.js)

import React, { useEffect } from 'react';
import { CallHandler } from 'rns-nativecall';

export default function App() {
  useEffect(() => {
    const unsubscribe = CallHandler.subscribe(
      (data) => {
        console.log("Call Accepted:", data.callUuid);
        // Navigate to your call screen
      },
      (data) => {
        console.log("Call Rejected:", data.callUuid);
        // Send 'Hangup' signal to your server
      }
    );

    return () => unsubscribe();
  }, []);

  // To manually trigger the UI (e.g., from an FCM data message)
  const showCall = () => {
    CallHandler.displayCall("unique-uuid", "Caller Name", "video");
  };

  return <YourUI />;
}

📖 API Reference

rns-nativecall API Reference

| Method | Platform | Description | | :--- | :--- | :--- | | registerHeadlessTask(callback) | Android | Registers background logic. eventType is INCOMING_CALL or BUSY. | | checkOverlayPermission() | Android | Returns true if the app can draw over other apps (Required for Android Lockscreen). | | requestOverlayPermission() | Android | Opens System Settings to let the user enable "Draw over other apps". | | displayCall(uuid, name, type) | All | Shows the native call UI (Standard Notification on Android / CallKit on iOS). | | checkCallValidity(uuid) | All | Returns boolean values for isValid and isCanceled. | | stopForegroundService() | Android | Stops the ongoing service and clears the persistent notification/pill. | | destroyNativeCallUI(uuid) | All | Dismisses the native call interface and stops the ringtone. | | getInitialCallData() | All | Returns call data if the app was launched by clicking Answer from a killed state. | | subscribe(onAccept, onReject) | All | Listens for native button presses (Answer/End). |


Implementation Notes

  1. Android Persistence: Because this library uses a Foreground Service on Android, the notification will persist and show a "Call Pill" in the status bar. To remove this after the call ends or connects, you MUST call 'CallHandler.stopForegroundService()'.

  2. Android Overlay: For your React Native call screen to show up when the phone is locked, the user must grant the "Overlay Permission". Use 'checkOverlayPermission()' and 'requestOverlayPermission()' during your app's onboarding or call initiation.

  3. iOS CallKit: On iOS, 'displayCall' uses the native system CallKit UI. This works automatically in the background and on the lockscreen without extra overlay permissions.

  4. Single Call Gate: The library automatically prevents multiple overlapping native UIs. If a call is already active, subsequent calls will trigger the 'BUSY' event in your Headless Task.


FULL Example Use Case

import React, { useEffect, useState } from 'react';
import { StyleSheet, Text, View, TouchableOpacity, Alert } from 'react-native';
import { CallHandler } from 'rns-nativecall';

export default function App() {
  const [activeCall, setActiveCall] = useState(null);

  useEffect(() => {
    // 1. Handle app launched from a notification "Answer" click
    CallHandler.getInitialCallData().then((data) => {
      if (data && data.default) {
        console.log("App launched from call:", data.default);
        setActiveCall(data.default);
      }
    });

    // 2. Subscribe to foreground events
    const unsubscribe = CallHandler.subscribe(
      (data) => {
        console.log("Call Accepted:", data.callUuid);
        setActiveCall(data);
        // Logic: Open your Video/Audio Call UI here
      },
      (data) => {
        console.log("Call Rejected/Ended:", data.callUuid);
        setActiveCall(null);
      }
    );

    return () => unsubscribe();
  }, []);

  const startTestCall = async () => {
    // Android Only: Check for overlay permission to show UI over lockscreen
    const hasPermission = await CallHandler.checkOverlayPermission();
    if (!hasPermission) {
      Alert.alert(
        "Permission Required",
        "Please enable 'Draw over other apps' to see calls while the phone is locked.",
        [
          { text: "Cancel" },
          { text: "Settings", onPress: () => CallHandler.requestOverlayPermission() }
        ]
      );
      return;
    }

    // Trigger the native UI
    CallHandler.displayCall(
      "test-uuid-" + Date.now(),
      "John Doe",
      "video"
    );
  };

  const endCallManually = () => {
    if (activeCall) {
      CallHandler.stopForegroundService();
      setActiveCall(null);
    }
  };

  return (
    <View style={styles.container}>
      <Text style={styles.title}>RNS Native Call Pro</Text>
      
      {activeCall ? (
        <View style={styles.callBox}>
          <Text>Active Call with: {activeCall.name}</Text>
          <TouchableOpacity style={styles.btnEnd} onPress={endCallManually}>
            <Text style={styles.btnText}>End Call</Text>
          </TouchableOpacity>
        </View>
      ) : (
        <TouchableOpacity style={styles.btnStart} onPress={startTestCall}>
          <Text style={styles.btnText}>Simulate Incoming Call</Text>
        </TouchableOpacity>
      )}
    </View>
  );
}

const styles = StyleSheet.create({
  container: { flex: 1, justifyContent: 'center', alignItems: 'center', backgroundColor: '#F5FCFF' },
  title: { fontSize: 20, fontWeight: 'bold', marginBottom: 20 },
  callBox: { padding: 20, backgroundColor: '#e1f5fe', borderRadius: 10, alignItems: 'center' },
  btnStart: { backgroundColor: '#4CAF50', padding: 15, borderRadius: 5 },
  btnEnd: { backgroundColor: '#F44336', padding: 15, borderRadius: 5, marginTop: 10 },
  btnText: { color: 'white', fontWeight: 'bold' }
});

🛡 License