npm.io
1.1.3 • Published 3 weeks ago

stringee-react-native-v2

Licence
MIT
Version
1.1.3
Deps
0
Size
703 kB
Vulns
0
Weekly
0

stringee-react-native-v2

React Native SDK for adding Stringee voice/video calls, custom messages, chat, and live-chat features to Android and iOS applications.

The package supports the same package-root imports in JavaScript and TypeScript. JavaScript consumers receive precompiled CommonJS; TypeScript consumers also receive strict declarations.

Requirements

  • React Native >=0.60
  • iOS 13.0 or later
  • AndroidX-enabled Android project
  • A Stringee access token generated by a trusted backend

Expo is supported through a development build or a production build. Expo Go is not supported because this package contains custom native modules and a native video view.

Installation

npm install stringee-react-native-v2

Expo projects

The limitation of older Expo managed projects was Expo Go: its native binary contains only the native libraries selected by Expo. It cannot load this SDK at runtime. Current Expo projects can use the SDK by compiling it into a custom development or production build.

Stringee remains a standard React Native native library; it does not need to be rewritten as an Expo Module. Expo autolinking discovers RNStringeeReactPackage on Android and RNStringee.podspec on iOS. Do not add expo-module.config.json, manually register RNStringeeReactPackage, or add the pod by hand.

Expo runtime Supported Required action
Expo Go / Snack using Expo Go No Use a development build instead
Local development build Yes Run npx expo run:android or npx expo run:ios
EAS development/preview/production build Yes Build a new native binary with EAS
OTA JavaScript update Yes, after installation Cannot add or upgrade the native SDK by itself

Autolinking does not configure permissions owned by the host application. This release does not include an Expo config plugin, so a project that uses Expo CNG must declare them in app.json or app.config.js:

{
  "expo": {
    "ios": {
      "infoPlist": {
        "NSCameraUsageDescription": "This app uses the camera for video calls.",
        "NSMicrophoneUsageDescription": "This app uses the microphone for calls."
      }
    },
    "android": {
      "permissions": [
        "android.permission.INTERNET",
        "android.permission.ACCESS_NETWORK_STATE",
        "android.permission.ACCESS_WIFI_STATE",
        "android.permission.RECORD_AUDIO",
        "android.permission.MODIFY_AUDIO_SETTINGS",
        "android.permission.CAMERA",
        "android.permission.BLUETOOTH",
        "android.permission.BLUETOOTH_CONNECT"
      ]
    }
  }
}

These entries add build-time declarations only. On Android, request camera, microphone, and BLUETOOTH_CONNECT at runtime with React Native's PermissionsAndroid before using the related call feature.

Create and run a development build instead of opening the application in Expo Go:

npx expo install expo-dev-client
npx expo prebuild --clean
npx expo run:android
# or
npx expo run:ios

EAS Build also works. When the repository does not contain android and ios directories, EAS applies the app config during prebuild. Rebuild the development client after installing or upgrading this SDK because its native binaries have changed.

Running only npx expo start or npx expo prebuild is not enough on first installation: prebuild generates the native projects, but the development client still has to be compiled and installed. A Stringee config plugin is not required for native module registration; a config plugin is only needed to automate native configuration that cannot be represented in app config.

Do not edit generated AndroidManifest.xml or Info.plist in a CNG project. A local config plugin is only needed for optional <uses-feature> declarations or the legacy Bluetooth permission's maxSdkVersion="30" attribute.

See Expo's documentation for development builds, permissions, and config plugins. The expo-build-properties reference documents android.extraProguardRules.

This integration was verified with a clean Expo SDK 57 / React Native 0.86 fixture using New Architecture: Expo detected both native targets, Android assembleDebug completed, and the iOS RNStringee pod compiled for the simulator. A TypeScript screen importing StringeeClient and rendering StringeeVideoView also passed type checking and Metro's Android export.

React Native projects with native folders

iOS

Install CocoaPods dependencies:

cd ios
pod install
cd ..

Open the generated .xcworkspace rather than the .xcodeproj. Add camera and microphone usage descriptions to the application Info.plist:

<key>NSCameraUsageDescription</key>
<string>$(PRODUCT_NAME) uses the camera for video calls.</string>
<key>NSMicrophoneUsageDescription</key>
<string>$(PRODUCT_NAME) uses the microphone for calls.</string>

The podspec resolves Stringee iOS SDK 2.0.2 automatically.

Android

Enable AndroidX in the application gradle.properties:

android.useAndroidX=true

Add the required permissions and hardware declarations to android/app/src/main/AndroidManifest.xml:

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission
    android:name="android.permission.BLUETOOTH"
    android:maxSdkVersion="30" />
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />

<uses-feature android:name="android.hardware.camera" android:required="false" />
<uses-feature android:name="android.hardware.camera.autofocus" android:required="false" />
<uses-feature android:name="android.hardware.bluetooth" android:required="false" />
<uses-feature android:name="android.hardware.bluetooth_le" android:required="false" />
<uses-feature android:glEsVersion="0x00020000" android:required="false" />

Request camera, microphone, and any required Bluetooth permission at runtime on Android versions where they are dangerous permissions.

Stringee Android SDK 2.1.18 includes its required R8 rules. Do not add package-wide Stringee or WebRTC keep rules to the host application.

The package resolves Stringee Android SDK 2.1.18 and WebRTC 150.7871.01. Do not add separate Stringee, WebRTC, or Volley dependencies to the host app.

JavaScript and TypeScript projects

JavaScript and TypeScript projects use the same native setup and the same package-root imports. No additional Babel or Metro configuration is required:

  • JavaScript receives compiled CommonJS and does not need TypeScript installed.
  • TypeScript resolves the bundled declarations automatically with a normal React Native or Expo tsconfig.json; skipLibCheck is not required.
  • Use named imports from stringee-react-native-v2. Do not import from src or lib/commonjs, because those are implementation paths.

JavaScript can use either module syntax supported by the application:

import {StringeeClient} from 'stringee-react-native-v2';

// CommonJS projects can use:
const {StringeeCall} = require('stringee-react-native-v2');

TypeScript can import runtime values normally and public interfaces as type-only imports:

import {StringeeClient} from 'stringee-react-native-v2';
import type {StringeeClientOptions} from 'stringee-react-native-v2';

const options: StringeeClientOptions = {};
const client = new StringeeClient(options);

When upgrading an existing app, remove any old deep imports into the package source. If Metro still serves declarations or JavaScript from the previous version, reinstall dependencies and restart it with npx expo start --clear or npx react-native start --reset-cache.

Basic usage

import {
  StringeeClient,
  StringeeClientListener,
} from 'stringee-react-native-v2';

const client = new StringeeClient();
const listener = new StringeeClientListener();

listener.onConnect = (_connectedClient, userId) => {
  console.log('Connected as', userId);
};

listener.onFailWithError = (_failedClient, code, message) => {
  console.error('Stringee connection failed', code, message);
};

listener.onIncomingCall = (_connectedClient, call) => {
  console.log('Incoming call from', call.from);
};

client.setListener(listener);
client.connect(accessToken);

Listeners use optional callbacks, so applications can assign only the events they need. On sign-out or component cleanup:

client.unregisterEvents();
client.disconnect();

Never embed a Stringee secret or long-lived production access token in the app.

Local example

The example app is a React Native 0.84 TypeScript consumer that links this repository through file:...

npm run example:install
npm run example:start

# Run in another terminal
npm run example:android
# or
npm run example:ios

See example/README.md for supported flows and native prerequisites.

Documentation

Keywords