$ yarn add react-native-vivox
$ react-native link react-native-vivox
- Unzip
aar.zip
(download) inandroid
- Add the following code in
android/app/build.gradle
repositories {
flatDir {
dirs "../aar"
}
}
dependencies {
// ...
debugImplementation(name: 'sdk-debug', ext: 'aar')
releaseImplementation(name: 'sdk-release', ext: 'aar')
}
- Add the following code in
android/app/src/main/java/com.package.name/MainApplication.java
import com.vivox.sdk.JniHelpers; // <-- this line
// ...
@Override
public void onCreate() {
super.onCreate();
JniHelpers.init(getApplicationContext(), null, new String[]{"mvc"}); // <-- this line
}
- Add (link)
libvivoxsdk.a
(from/react-native-vivox/ios/core/Libraries/${CONFIGURATION}/libvivoxsdk.a
) into Frameworks - Add (link)
libresolv.tbd
(download) into Frameworks - Add the following to your App's
Info.plist
<key>NSMicrophoneUsageDescription</key>
<string>Need microphone access to communicate with other players</string>
<key>UIBackgroundModes</key>
<array>
<string>audio</string>
<string>voip</string>
</array>
This example will connect your app to your Vivox server and join the test123
voice channel. Make sure you requested microphone permission before!
import React from 'react';
import * as Vivox from 'react-native-vivox';
class App extends React.Component {
async componentDidMount(): void {
await Vivox.connect("https://vdx5.www.vivox.com/api2/", "issuer", "vdx5.vivox.com");
await Vivox.login("userId", "loginToken");
await Vivox.joinChannel("test123", "joinToken");
}
render() {
return null;
}
}
export default App;
Example app: https://github.com/lucienbl/react-native-vivox-demo
Vivox.connect("server", "issuer", "realm"); // returns Promise<>
Vivox.login("userId", "loginToken"); // returns Promise<>
Vivox.joinChannel("channelId", "joinToken"); // returns Promise<>
Vivox.leaveChannel(); // returns Promise<>
Vivox.disconnect(); // returns Promise<>
Vivox.getState(); // returns Promise<number>
Vivox.getStateName(); // returns Promise<string>
Vivox.muteMyself(true); // returns Promise<>
Vivox.isMuted(); // returns Promise<boolean>
Vivox.getSpeakingParticipants(); // returns Promise<Object>
Vivox.setParticipantMutedForMe("targetUserId", true); // returns Promise<>
Vivox.setAudioOutputDeviceMuted(true); // returns Promise<>
Vivox.setParticipantAudioOutputDeviceVolumeForMe("targetUserId", 50); // returns Promise<>