1.0.1 • Published 2 years ago

@xendoc/react-native-jitsi-meet v1.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

React Native JitsiMeet

React Native Wrapper for Jitsi Meet SDK.

Install

yarn add @xendoc/react-native-jitsi-meet

or

npm i --save @xendoc/react-native-jitsi-meet

Only supports React Native >= 0.60.

Usage

The package can be invoked in two modes

  1. As a new Activity/UIViewController on top of RN Application
  2. As a RN View
import JitsiMeet, { JitsiMeetView } from '@xendoc/react-native-jitsi-meet';
import React, { useState } from 'react';
import { StyleSheet } from 'react-native';

const conferenceOptions = {
  room: 'ReactNativeJitsiRoom',
  userInfo: {
    displayName: 'React Native Jitsi Meet Example',
    email: 'example@test.com',
    avatar: 'https://picsum.photos/200',
  },
  pipEnabled: false,
};

function App() {
  const [showJitsiView, setShowJitsiView] = useState(false);

  const startJitsiAsNativeController = () => {
    /*
      Mode 1 - Starts a new Jitsi Activity/UIViewController
      on top of RN Application (outside of JS).
      It doesn't require rendering <JitsiMeetView />.
    */
    JitsiMeet.launch(conferenceOptions);
  };

  const startJitsiView = () => setShowJitsiView(true);

  const onConferenceTerminated = () => setShowJitsiView(false);

  return (
    showJitsiView && (
      /* Mode 2 - Starts Jitsi as a RN View */
      <JitsiMeetView
        style={styles.jitsiMeetView}
        options={conferenceOptions}
        onConferenceTerminated={onConferenceTerminated}
      />
    )
  );
}

const styles = StyleSheet.create({
  jitsiMeetView: {
    flex: 1,
  },
});

export default App;

See Options for further information.

iOS install

1.) This library uses Swift code, so make sure that you have created the Objective-C bridging header file.

If not, open your project in Xcode and create an empty Swift file.

Xcode will ask if you wish to create the bridging header file, please choose yes.

For more information check Create Objective-C bridging header file.

2.) Replace the following code in AppDelegate.m (ONLY required for mode 1. If you're using mode 2, skip this step):

UIViewController *rootViewController = [UIViewController new];
rootViewController.view = rootView;
self.window.rootViewController = rootViewController;

with this one

UIViewController *rootViewController = [UIViewController new];
UINavigationController *navigationController = [[UINavigationController alloc]initWithRootViewController:rootViewController];
navigationController.navigationBarHidden = YES;
rootViewController.view = rootView;
self.window.rootViewController = navigationController;

This will create a navigation controller to be able to navigate between the Jitsi component and your react native screens.

3.) Add the following lines to your Info.plist

<key>NSCameraUsageDescription</key>
<string>Camera Permission</string>
<key>NSMicrophoneUsageDescription</key>
<string>Microphone Permission</string>
<key>NSCalendarUsageDescription</key>
<string>Calendar Permission</string>

4.) Modify your platform version in Podfile and Xcode to have platform version 11.0 or above.

5.) In Xcode, under Build settings set Enable Bitcode to No and Always Embed Swift Standard Libraries to Yes.

6.) In Xcode, under Signing & Capabilities add the capability Background Modes and check VoIP. Otherwise, it won't work well in background.

7.) Clean your project and run npx pod-install.

Android install

Important

There seems to be an issue with RN >= 0.64 and Jitsi SDK, as buttons dont't respond and other bugs, so until the issue is sorted out it is advised to use the RN 0.63

1.) In android/app/build.gradle, add/replace the following lines:

project.ext.react = [
    entryFile: "index.js",
    bundleAssetName: "app.bundle",
    ...
]

2.) In android/app/src/main/java/com/xxx/MainApplication.java add/replace the following methods:

  import androidx.annotation.Nullable; // <--- Add this line if not already existing
  ...
    @Override
    protected String getJSMainModuleName() {
      return "index";
    }

    @Override
    protected @Nullable String getBundleAssetName() {
      return "app.bundle";
    }

3.) In android/build.gradle, add the following code

allprojects {
    repositories {
        mavenLocal()
        jcenter()
        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url "$rootDir/../node_modules/react-native/android"
        }
        maven {
            url "https://maven.google.com"
        }
        maven { // <---- Add this block
            url "https://github.com/jitsi/jitsi-maven-repository/raw/master/releases"
        }
        maven { url "https://jitpack.io" }
    }
}

4.) In the <application> section of android/app/src/main/AndroidManifest.xml, add (ONLY required for mode 1. If you're using mode 2, skip this step)

<activity
    android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|screenSize|smallestScreenSize"
    android:launchMode="singleTask"
    android:resizeableActivity="true"
    android:supportsPictureInPicture="true"
    android:windowSoftInputMode="adjustResize"
    android:name="com.reactnativejitsimeet.JitsiMeetActivityExtended">
</activity>

5.) And set your minSdkVersion to be at least 24.

buildscript {
    ext {
        buildToolsVersion = "29.0.3"
        minSdkVersion = 24 // <-- this line
        compileSdkVersion = 29
        targetSdkVersion = 29
        ndkVersion = "20.1.5948944"
    }
    ...
}

6.) Remove allow back up from Androidmanifest.xml

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
  package="com.sdktest">

    <uses-permission android:name="android.permission.INTERNET" />

    <application
      android:name=".MainApplication"
      android:label="@string/app_name"
      android:icon="@mipmap/ic_launcher"
      android:roundIcon="@mipmap/ic_launcher_round"
      android:allowBackup="false" <-- this line
      android:theme="@style/AppTheme">
      <activity
        android:name=".MainActivity"
        android:label="@string/app_name"
        android:configChanges="keyboard|keyboardHidden|orientation|screenSize|uiMode"
        android:launchMode="singleTask"
        android:windowSoftInputMode="adjustResize">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
      </activity>
    </application>
</manifest>

Options

keyData typeDefaultDescription
roomstringrequiredRoom name for Jitsi Meet
serverUrlstringhttps://meet.jit.siValid server URL
tokenstring""JWT token
userInfoobject{}Object that contains information about the participant starting the meeting. See UserInfo
screenSharingEnabledbooleantrue (android) false (iOS)Flag indicating if screen sharing should be enabled
conferenceTimerEnabledbooleantrueFlag indicating if conference timer should be enabled
addPeopleEnabledbooleantrueFlag indicating if add-people functionality should be enabled
calendarEnabledbooleantrue (android) auto-detected (iOS)Flag indicating if calendar integration should be enabled
inviteEnabledbooleantrueFlag indicating if invite functionality should be enabled
meetingPasswordEnabledbooleantrueFlag indicating if the meeting password button should be enabled
recordingEnabledbooleanauto-detected (android) false (iOS)Flag indicating if recording should be enabled
liveStreamingEnabledbooleanauto-detectedFlag indicating if live-streaming should be enabled
raiseHandEnabledbooleantrueFlag indicating if raise hand feature should be enabled
serverUrlChangeEnabledbooleantrueFlag indicating if server URL change is enabled
videoShareEnabledbooleantrueFlag indicating if the video share button should be enabled
securityOptionsEnabledbooleantrueFlag indicating if the security options button should be enabled
chatEnabledbooleantrueFlag indicating if chat should be enabled
lobbyModeEnabledbooleantrueFlag indicating if lobby mode button should be enabled
pipEnabledbooleantrue (android)Flag indicating if Picture-in-Picture should be enabled (only Android)

UserInfo

keyData typeDefaultDescription
displayNamestring""Participant's name
emailstring""Participant's e-mail
avatarstring""Participant's avatar URL

Screen Sharing

It is already enabled by default on Android.

On iOS it requires a few extra steps. Set the flag screenSharingEnabled to true and follow this tutorial Screen Sharing iOS to get it working.

Instructions to run the example app

1.) Clone this project

git clone https://github.com/XenDoc/react-native-jitsi-meet.git

2.) Navigate to the project folder

cd react-native-jitsimeet

3.) Install dependencies

yarn

4.) Run app

yarn example ios

or

yarn example android

Troubleshooting

If your having problems with duplicate_classes errors, try exclude them from the react-native-jitsimeet project implementation with the following code:

implementation(project(':react-native-jitsimeet')) {
  // Un-comment below if using hermes
  exclude group: 'com.facebook',module:'hermes'
  // Un-comment any packages below that you have added to your project to prevent `duplicate_classes` errors
  exclude group: 'com.facebook.react',module:'react-native-locale-detector'
  exclude group: 'com.facebook.react',module:'react-native-vector-icons'
  // exclude group: 'com.facebook.react',module:'react-native-community-async-storage'
  // exclude group: 'com.facebook.react',module:'react-native-community_netinfo'
  // exclude group: 'com.facebook.react',module:'react-native-svg'
  // exclude group: 'com.facebook.react',module:'react-native-fetch-blob'
  // exclude group: 'com.facebook.react',module:'react-native-webview'
  // exclude group: 'com.facebook.react',module:'react-native-linear-gradient'
  // exclude group: 'com.facebook.react',module:'react-native-sound'
}