At a glance
| Platform | Package | Install | Requires |
|---|---|---|---|
| Flutter | gravix_rtc on pub.dev | flutter pub add gravix_rtc | Flutter 3.38+, Dart 3.10+ |
| Web | gravix-rtc on npm | npm install gravix-rtc | A browser with WebRTC, page served over HTTPS |
| React Native | gravix-rtc-react-native on npm | npm | React Native 0.79+ (old or New Architecture), Android 7.0+, iOS 13+ |
| Android (Kotlin, Java) | com.gravixcloud:gravix-rtc-android on Maven Central | Gradle | Android 7.0 (API 24)+ |
| iOS | gravix_rtc (Flutter) | As Flutter | iOS 13+ |
Before you start
Every SDK joins a room with an access token that your server signs with your App ID and App Certificate. The App Certificate never goes into an app. If you have not built that endpoint yet, start with access tokens: it is about twenty lines of Node or Go.
In the examples below, https://YOUR-BACKEND/rtc/token is that endpoint. It answers with { token, url }, where url is your region URL from the dashboard (wss://YOUR-REGION-URL).
Flutter
gravix_rtc is one package with one import. GravixRoomService runs the room: connect and leave, mic and camera, active speakers and reconnects, with state exposed as ValueNotifiers.
Install
flutter pub add gravix_rtcPlatform setup
Declare microphone and camera access for each platform you ship. Ask for the permissions at runtime before the user joins with mic or camera on.
<!-- android/app/src/main/AndroidManifest.xml -->
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<!-- Bluetooth headsets: Android 12+ needs BLUETOOTH_CONNECT -->
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
<uses-permission android:name="android.permission.BLUETOOTH" android:maxSdkVersion="30" />
<!-- ... your <application> ... -->
</manifest><!-- ios/Runner/Info.plist -->
<key>NSMicrophoneUsageDescription</key>
<string>Talk in calls</string>
<key>NSCameraUsageDescription</key>
<string>Video in calls</string>
<!-- Keep call audio playing with the screen locked or the app in the background -->
<key>UIBackgroundModes</key>
<array>
<string>audio</string>
</array>Join a room
import 'package:gravix_rtc/gravix_rtc.dart';
// One provider per signed-in user. It caches each token until it is about to expire.
final tokens = GravixTokenProvider.endpoint(
Uri.parse('https://YOUR-BACKEND/rtc/token'),
headers: {'Authorization': 'Bearer $sessionJwt'}, // your app's own login session
);
final room = GravixRoomService();
Future<void> join(String roomId, String userId, String name) async {
room.onRemoteVideoTrack = (uid, track) {
// show it with VideoTrackRenderer(track)
};
final ok = await room.connectWithTokenProvider(
tokenProvider: tokens,
request: GravixTokenRequest(
room: roomId,
identity: userId,
name: name,
canPublish: true,
),
publishMic: true,
enableVideo: true,
);
if (!ok) {
// room.lastTokenError is set when your token endpoint failed
}
}
Future<void> leave() => room.disconnect();canPublishin the request is what the app asks for. Your server decides what goes into the token.- Build one token provider per signed-in user and keep it: tokens are cached until shortly before they expire, so a join does not wait for your server twice.
room.activeSpeakerstells you who is talking, for a speaking ring or a seat glow.
Audio defaults (0.5.0 and later)
- Noise suppression is on by default: the device picks standard or studio suppression. To keep WebRTC's own noise suppression, as before 0.5.0, pass
GravixRoomService(noiseSuppression: GravixNoiseSuppressionOptions.off). - Opus DTX is on by default: during silence the microphone sends almost nothing. Opt out with
dtx: falseonconnectWithTokenProvider. - iOS: an app that needs the microphone in the background must declare the
audiobackground mode (UIBackgroundModes) inInfo.plist, as in platform setup. - Gift or entrance effects your app plays itself (SVGA, MP4) can reach the room through the microphone. On Android,
GravixAudioScenario.chatRoom(0.5.2 and later) uses call mode and the phone's echo canceller, so they are not sent. CallGravixRtcClient.initialize(audioScenario: GravixAudioScenario.chatRoom)before anything else. The trade-offs: call volume, voice-band capture, other apps cannot record while the microphone runs, and screen recordings do not capture the room. - Joins route by what each region takes: a join with video goes to the best measured region that takes video, an audio-only join may use any. If a server refuses a medium, the session moves once and republishes the camera. Nothing to set up.
Web and React
gravix-rtc is the browser SDK, written in TypeScript, for plain pages and for React or any other framework. The browser asks the user for microphone and camera access the first time you turn them on, and only on pages served over HTTPS (a local development server on your own machine also works).
Install
npm install gravix-rtcJoin a room
import { Room, RoomEvent, GravixTokenProvider, connectWithTokenProvider } from 'gravix-rtc';
// Calls YOUR backend with the user's session cookie. Tokens are cached until they expire.
const tokens = GravixTokenProvider.endpoint('https://YOUR-BACKEND/rtc/token', {
credentials: 'include',
});
const room = new Room();
const stage = document.getElementById('stage')!;
room
.on(RoomEvent.TrackSubscribed, (track) => {
stage.appendChild(track.attach()); // a <video> or <audio> element
})
.on(RoomEvent.TrackUnsubscribed, (track) => {
track.detach().forEach((el) => el.remove());
});
export async function join(roomId: string, userId: string, name: string) {
await connectWithTokenProvider(room, {
tokenProvider: tokens,
request: { room: roomId, identity: userId, name },
});
await room.localParticipant.setMicrophoneEnabled(true);
await room.localParticipant.setCameraEnabled(true);
}
export const leave = () => room.disconnect();credentials: 'include'sends your app's session cookie, so your endpoint knows who is asking. You can passheadersinstead.track.attach()returns a ready<video>or<audio>element for each remote track.- Turn the camera off with
room.localParticipant.setCameraEnabled(false), and the microphone the same way. - From 0.7.0 noise suppression is on by default, and the microphone is sent in mono with Opus DTX, so silence costs almost nothing.
React Native
gravix-rtc-react-native (0.3.0) is the SDK for React Native apps on Android and iOS. It is built on the web SDK, gravix-rtc, and re-exports all of it (rooms, tracks, events, tokens, fast join), and adds the camera and audio session, video views, hooks and the native audio features of the Flutter SDK.
0.3.0 is tested on Android phones, on React Native 0.79 (old architecture) and 0.88 (New Architecture), with one package for both; iOS is build- and unit-tested only. When a camera join gets stuck on the low video layer, the SDK reconnects by itself (at most twice per room); turn it off withregisterGlobals({ publishStallRecovery: false }). Details are in the package's CHANGELOG.md.
Install
npm install gravix-rtc-react-native gravix-rtc@^0.11.0 react-native-webrtc@^155.0.0Expo Go is not supported; use a development build.
Setup
// metro.config.js
const { getDefaultConfig } = require('@react-native/metro-config');
const { withGravixRtc } = require('gravix-rtc-react-native/metro');
module.exports = withGravixRtc(getDefaultConfig(__dirname));// MainApplication.kt, in onCreate() before loadReactNative(this)
import com.gravitycompile.gravixrtc.GravixRtc
GravixRtc.setup(this)// AppDelegate.swift, before React Native starts
import gravix_rtc_react_native
GravixRtcSetup.setup()- The Metro step is required: without it the Hermes bundle does not compile.
- Android: the library adds the permissions it needs; request camera and microphone at runtime.
GravixRtc.setup(this, audioScenario = "chatRoom")picks the chat-room audio scenario, as in Flutter. - iOS: run
pod install, and addNSCameraUsageDescription,NSMicrophoneUsageDescriptionand theaudiobackground mode toInfo.plist. The native audio features (voice effects, noise suppression, room music) are an opt-in beta on iOS.
Join a room
// index.js: once, before any Room exists
import { registerGlobals } from 'gravix-rtc-react-native';
registerGlobals();
// call.tsx
import {
AudioSession, GravixRoomProvider, GravixTokenProvider, Room, Track,
connectWithTokenProvider, useRoom, VideoView,
} from 'gravix-rtc-react-native';
// Calls YOUR backend. Tokens are cached until they expire.
const tokens = GravixTokenProvider.endpoint('https://YOUR-BACKEND/rtc/token');
export async function join(roomId: string, userId: string, name: string) {
const room = new Room({ adaptiveStream: true, dynacast: true });
await AudioSession.startAudioSession();
await connectWithTokenProvider(room, {
tokenProvider: tokens,
request: { room: roomId, identity: userId, name },
});
await room.localParticipant.setMicrophoneEnabled(true);
return room;
}
export async function leave(room: Room) {
await room.disconnect();
await AudioSession.stopAudioSession();
}
function RoomScreen() {
const { tracks } = useRoom(undefined, { sources: [Track.Source.Camera] });
return tracks.map((t) => (
<VideoView key={t.publication.trackSid} trackRef={t} style={{ height: 200 }} />
));
}
// <GravixRoomProvider room={room}><RoomScreen /></GravixRoomProvider>registerGlobals()must run once, before anyRoomexists.- Muting the microphone closes it (the system mic indicator goes off), as in Flutter 0.12.1 and later.
- Fast join: use
createGravixJoin({ tokenProvider }). It is the sameGravixJoinas in fast join, with the app going to the background as the join guard. - Speaker on or off:
AudioSession.setSpeakerphoneOn(true).
Android (Kotlin, Java)
com.gravixcloud:gravix-rtc-android is the native Android SDK, for apps written in Kotlin or Java. Kotlin uses Room with coroutines and event flows; Java uses GravixRoomService, with CompletableFutures and a listener. Building with Flutter instead? Use gravix_rtc and the Flutter steps; the notes below apply to both.
Install
// settings.gradle.kts: everything resolves from Google and Maven Central
dependencyResolutionManagement {
repositories {
google()
mavenCentral()
}
}
// app/build.gradle.kts
dependencies {
implementation("com.gravixcloud:gravix-rtc-android:0.2.0")
}Join a room
Ask your token endpoint for { token, url }, then join with them.
import com.gravixcloud.rtc.GravixRtc
import com.gravixcloud.rtc.events.RoomEvent
import com.gravixcloud.rtc.events.collect
import com.gravixcloud.rtc.regions.GravixRegionMeasurements
import com.gravixcloud.rtc.renderer.SurfaceViewRenderer
import com.gravixcloud.rtc.room.track.VideoTrack
class CallActivity : AppCompatActivity() {
private val room by lazy { GravixRtc.create(applicationContext) }
// url and token come from YOUR backend: POST https://YOUR-BACKEND/rtc/token -> { token, url }.
// Call after RECORD_AUDIO and CAMERA are granted.
private fun join(url: String, token: String, renderer: SurfaceViewRenderer) {
room.initVideoRenderer(renderer)
lifecycleScope.launch {
launch {
room.events.collect { event ->
when (event) {
is RoomEvent.TrackSubscribed -> (event.track as? VideoTrack)?.addRenderer(renderer)
is RoomEvent.Resuming, is RoomEvent.Reconnecting -> showReconnecting(true)
is RoomEvent.Resumed, is RoomEvent.Reconnected -> showReconnecting(false)
else -> Unit
}
}
}
// the measured nearest region when one was measured, else url unchanged
room.connect(GravixRegionMeasurements.resolveConnectUrl(url), token)
room.localParticipant.setMicrophoneEnabled(true)
room.localParticipant.setCameraEnabled(true)
}
}
private fun showReconnecting(on: Boolean) {
title = if (on) "Reconnecting..." else "In call"
}
override fun onDestroy() {
room.disconnect()
super.onDestroy()
}
}import com.gravixcloud.rtc.regions.GravixRegionMeasurements;
import com.gravixcloud.rtc.renderer.SurfaceViewRenderer;
import com.gravixcloud.rtc.room.track.VideoTrack;
import com.gravixcloud.rtc.service.GravixRoomService;
import com.gravixcloud.rtc.service.GravixRoomServiceListener;
public class CallActivity extends Activity {
private GravixRoomService service;
// url and token come from YOUR backend: POST https://YOUR-BACKEND/rtc/token -> { token, url }.
// Call after RECORD_AUDIO and CAMERA are granted.
private void join(String url, String token, SurfaceViewRenderer renderer) {
service = new GravixRoomService(this);
service.initVideoRenderer(renderer);
service.addListener(new GravixRoomServiceListener() {
@Override
public void onRemoteVideoTrack(String uid, VideoTrack track) {
track.addRenderer(renderer);
}
@Override
public void onReconnecting(boolean isResume) {
setTitle("Reconnecting...");
}
@Override
public void onReconnected(boolean isResume) {
setTitle("In call");
}
});
// Futures complete on the main thread: never get() or join() them there.
service.connect(GravixRegionMeasurements.resolveConnectUrl(url), token)
.thenCompose(v -> service.setMicrophoneEnabled(true))
.thenCompose(micOn -> service.setCameraEnabled(true))
.exceptionally(error -> {
setTitle("Could not join");
return null;
});
}
@Override
protected void onDestroy() {
if (service != null) service.release();
super.onDestroy();
}
}- Minimum Android 7.0 (API 24).
- From 0.2.0 noise suppression is on by default. To keep WebRTC's own noise suppression, set
RoomOptions(noiseSuppression = GravixNoiseSuppressionOptions.OFF). - Permissions:
RECORD_AUDIOandCAMERA, requested at runtime;BLUETOOTH_CONNECTon Android 12+ so Bluetooth headsets are found (the same list as in platform setup, inapp/src/main/AndroidManifest.xml). - Short network drops are resumed by the SDK: show "Reconnecting..." on
RoomEvent.Resuming(Java:onReconnecting) and clear it onResumed.
Android with Flutter: background calls
On Android 11 and later an app that is not on screen loses its microphone a few seconds after the user leaves it. The Flutter SDK ships a foreground service for calls. It is off by default; turn it on once before the first join.
// Android: keep the microphone alive when the user leaves the app (off by default).
// Turn it on once, before the first join.
GravixForegroundService.defaults = const GravixForegroundServiceOptions(
enabled: true,
notificationTitle: 'Live room',
notificationText: 'Tap to return',
showLeaveAction: true,
);
GravixForegroundService.leaveRequests.listen((_) => leave());The service needs RECORD_AUDIO granted before the user takes a seat. If your app already runs its own call service, keep this one off so users do not see two call notifications.
iOS
Build iOS apps with the Flutter SDK, gravix_rtc: follow the Flutter steps. A separate native iOS (Swift) SDK is not available today. If you need one, tell us.
- Minimum iOS 13.
NSMicrophoneUsageDescriptionandNSCameraUsageDescriptioninInfo.plist(see platform setup).- Add the
audiobackground mode (UIBackgroundModes) to keep a call audible with the screen locked. Since 0.5.0 it is required for any app that uses the microphone in the background. - The SDK manages the audio session: speaker, earpiece and Bluetooth routing work without extra code.
Fast join
For a room list, most of a join can happen before the tap. GravixJoin fetches the token while the card is on screen, starts the connect at the tap (not after the room screen opened) and hands that same connect to the room screen. It also leaves for you when the user goes back before the room opens, and keeps one session at a time. It is opt-in: the joins above work as before.
Warm on the list
Each room card on screen calls warm(request): its token goes into the cache, so the tap does not wait for your server. Warm the card under the finger too.
Prepare on tap
The tap calls prepare(request). The connect starts now, beside your own work and the navigation.
Attach on the room screen
The room screen calls attach(request) as it opens and gets the same connected room, with no second session. It returns null when the join failed or was abandoned.
Leave
leave() is the real exit. Call forgetAll() when another account signs in.
Build the request in one place: the warm-up and the tap must ask for the same room, identity and publish right, or the cached token is not used. Events from before attach are not replayed, so read the room's participants right after it, then listen.
import { useEffect, useRef, useState } from 'react';
import { GravixJoin, GravixTokenProvider, GravixTokenReuse, RoomEvent, type Room } from 'gravix-rtc';
// One GravixJoin per signed-in user (module scope or a context).
export const join = new GravixJoin({
tokenProvider: GravixTokenProvider.endpoint('https://YOUR-BACKEND/rtc/token', {
credentials: 'include', // your app's session cookie
reuse: GravixTokenReuse.fastJoin,
}),
});
// 1. The room list: warm every card on screen, and the one under the finger.
export function RoomCard({ roomId, rank, userId, onOpen }: { roomId: string; rank: number; userId: string; onOpen: () => void }) {
const request = { room: roomId, identity: userId };
useEffect(() => {
void join.warm(request, { role: 'visible', rank });
}, [roomId, rank, userId]);
return (
<button
onPointerDown={() => void join.warm(request)}
onClick={() => {
join.prepare(request); // 2. The tap: the connect starts now ...
onOpen(); // ... beside the navigation
}}
>
{roomId}
</button>
);
}
// 3. The room screen: attach to the connect the tap started (no second session).
export function RoomScreen({ roomId, userId, onClose }: { roomId: string; userId: string; onClose: () => void }) {
const [room, setRoom] = useState<Room | null>(null);
const mounted = useRef(false);
useEffect(() => {
mounted.current = true;
let active = true;
const request = { room: roomId, identity: userId };
const handle = join.pending(request) ?? join.prepare(request); // a cold join if there was no tap
const onGone = () => onClose();
void handle.attach().then((r) => {
if (!active) return;
if (!r) return onClose(); // failed, abandoned, or the page was hidden first
setRoom(r); // read r.remoteParticipants now, then listen
r.on(RoomEvent.Disconnected, onGone);
});
return () => {
active = false;
handle.room?.off(RoomEvent.Disconnected, onGone);
mounted.current = false;
// Leave one tick later: React StrictMode runs cleanup + effect at once in development.
setTimeout(() => {
if (!mounted.current) void handle.leave();
}, 0);
};
}, [roomId, userId]);
// 4. Leave: the real exit. join.forgetAll() when another account signs in.
// Stage and Joining are your own components.
return room ? <Stage room={room} onExit={() => void join.leave().then(onClose)} /> : <Joining />;
}import com.gravixcloud.rtc.join.GravixJoin
import com.gravixcloud.rtc.join.GravixJoinCredentials
import com.gravixcloud.rtc.join.GravixJoinRequest
import com.gravixcloud.rtc.join.GravixJoinTokenFetcher
import com.gravixcloud.rtc.join.GravixJoinTokenProvider
import com.gravixcloud.rtc.join.GravixTokenReuse
// Once per app (or per signed-in user), e.g. in Application.onCreate.
val tokens = GravixJoinTokenProvider(
GravixJoinTokenFetcher { r ->
// YOUR backend: POST https://YOUR-BACKEND/rtc/token -> { token, url }
val res = myBackend.rtcToken(r.room, r.identity, r.canPublish)
GravixJoinCredentials(res.url, res.token)
},
GravixTokenReuse.FAST_JOIN,
)
val join = GravixJoin.Builder(applicationContext, tokens).build()
val request = GravixJoinRequest(roomId, uid) // a viewer; GravixJoinRequest(roomId, uid, true) for a host
// 1. The room list: a card on screen gets its token now (no connect).
join.warmAsync(request)
// 2. The tap: the connect starts now, beside your own work and the navigation.
join.prepare(request)
// 3. The room screen, in onCreate: the same connect, no second session.
lifecycleScope.launch {
val room = join.attach(request) ?: return@launch finish() // null: failed or ended
// Events before attach are not replayed: read room.remoteParticipants now, then listen.
}
// 4. Leave: the real exit. join.forgetAll() when another account signs in.
lifecycleScope.launch { join.leave() }import com.gravixcloud.rtc.join.GravixJoin;
import com.gravixcloud.rtc.join.GravixJoinCredentials;
import com.gravixcloud.rtc.join.GravixJoinRequest;
import com.gravixcloud.rtc.join.GravixJoinTokenFetcher;
import com.gravixcloud.rtc.join.GravixJoinTokenProvider;
import com.gravixcloud.rtc.join.GravixTokenReuse;
// Once per app (or per signed-in user). myBackend.rtcToken returns a CompletableFuture
// of YOUR backend's answer: POST https://YOUR-BACKEND/rtc/token -> { token, url }.
GravixJoinTokenProvider tokens = new GravixJoinTokenProvider(
GravixJoinTokenFetcher.fromFuture(r ->
myBackend.rtcToken(r.getRoom(), r.getIdentity(), r.getCanPublish())
.thenApply(res -> new GravixJoinCredentials(res.url, res.token))),
GravixTokenReuse.FAST_JOIN);
GravixJoin join = new GravixJoin.Builder(getApplicationContext(), tokens).build();
GravixJoinRequest request = new GravixJoinRequest(roomId, uid); // a viewer (canPublish false)
// 1. The room list: a card on screen gets its token now (no connect).
join.warmAsync(request);
// 2. The tap: the connect starts now.
join.prepare(request);
// 3. The room screen's onCreate: the same connect (the future completes on the main thread).
join.prepare(request).attachAsync().thenAccept(room -> {
if (room == null) finish(); else show(room); // read room.getRemoteParticipants() now, then listen
});
// 4. Leave: the real exit. join.forgetAll() when another account signs in.
join.leaveAsync();import 'package:flutter/widgets.dart';
import 'package:gravix_rtc/gravix_rtc.dart';
// Once per signed-in user, after WidgetsFlutterBinding.ensureInitialized().
final join = GravixJoin(
tokenProvider: GravixTokenProvider.endpoint(
Uri.parse('https://YOUR-BACKEND/rtc/token'),
headers: {'Authorization': 'Bearer $sessionJwt'}, // your app's own login session
reuse: GravixTokenReuse.fastJoin,
),
);
// The ONE place the request is built: the warm-up and the tap must ask for the same token.
GravixTokenRequest requestFor(String roomId, String userId) =>
GravixTokenRequest(room: roomId, identity: userId, canPublish: false);
// 1. The room list: warm every card on screen, and the one under the finger.
void onCardVisible(String roomId, String userId, int index) =>
join.warm(requestFor(roomId, userId), role: GravixStandbyRole.visible, rank: index);
void onCardPointerDown(String roomId, String userId) => join.warm(requestFor(roomId, userId));
// 2. The tap: the connect starts now, beside the navigation.
void onCardTap(BuildContext context, String roomId, String userId) {
join.prepare(requestFor(roomId, userId));
Navigator.of(context).push(roomRoute(roomId)); // your own route
}
// 3. The room screen, from initState: the same connect, no second session.
Future<void> initRtc(String roomId, String userId) async {
final room = await join.attach(requestFor(roomId, userId)); // null: failed or abandoned
if (room == null) return closeScreen();
// Events before attach are not replayed: read room.remoteParticipants now, then listen.
}
// 4. Leave: the real exit. join.forgetAll() when another account signs in.
Future<void> leaveRoom() => join.leave();GravixJoinis ingravix-rtc0.6.9 and later (web and React),gravix-rtc-android0.1.2 and later, andgravix_rtc0.4.19 and later.- A web join is abandoned when the page is hidden or closed before
attach; once the room was shown, switching tabs or locking the phone never leaves it. On Android and Flutter the app going to the background plays the same part. - Moving from one room to another:
switchTo(next)stops the old session at once and connects the new one the moment it closed. - A gate after the tap refused the room (a password, a ban):
abandon(request).
Beauty effects
gravix_rtc 0.6.0 and later has built-in beauty effects: looks, face reshape, makeup, stickers and 3D effects on the camera, before the video is sent. They run on Android today; on iOS the room opens its normal camera. Try them first with the free Beauty Effects Demo app. Every look and slider, the licence and the React Native setup are in the beauty filter guide.
import 'dart:typed_data';
import 'package:gravix_rtc/gravix_rtc.dart';
// Android only today: on iOS the room opens its normal camera.
// effectsToken: your licence token from the console's Effects page.
// null (free plan) = the effects run with a Gravix Cloud watermark and QR code.
final beauty = GravixBeautyEffect(licenseToken: effectsToken);
final room = GravixRoomService(videoEffect: beauty);
// Optional, when the room screen opens: load the face model early,
// so the first video after app start is not late.
Future<void> onScreenOpen() => beauty.preload();
// Join as usual (connectWithTokenProvider). The effect opens the camera itself
// and the room publishes its picture as the camera track.
Future<void> pickLook(Uint8List gfxBytes) async {
await room.setVideoEffectParams({'look': 'glow'}); // a built-in look
await room.setVideoEffectParams({'lookBytes': gfxBytes}); // a .gfx look from Gravix Studio
await room.setVideoEffectParams({'reshape': {'faceSlim': 0.3}}); // also 'tone' and 'region'
}
Future<void> effectsOff() => room.setVideoEffectEnabled(false);- Pass the effect as
GravixRoomService(videoEffect: GravixBeautyEffect(licenseToken: ...)). Several effects run in order withvideoEffects: [...]. Camera on and off, flipping and leaving work as before. - Parameters for
setVideoEffectParams:look(a built-in look),lookBytes(a.gfxlook file exported from Gravix Studio), andtone,regionandreshapeadjustments.
React Native
gravix-rtc-react-native 0.3.0 and later has the same effects on Android, through two optional packages. Without them the app builds and the room uses its normal camera; on iOS it does too.
npm install react-native-gravix-effects@^1.5.0 react-native-gravix-effects-webrtc@^1.5.0import { GravixBeautyEffect, GravixRoomCamera } from 'gravix-rtc-react-native';
import { GravixPreview } from 'react-native-gravix-effects-webrtc';
const beauty = new GravixBeautyEffect({ licenseToken }); // null = watermark
beauty.preload(); // when the screen opens
await GravixBeautyEffect.ensurePack(onProgress); // gravixEffectsPack=models: download on first use
const camera = new GravixRoomCamera(room, { videoEffect: beauty });
await camera.connect(url, token); // url + token from your server; the camera opens during the connect
await camera.setVideoEffectParams({ look: 'glow' });
await camera.setVideoEffectParams({ tone: { smoothness: 0.7 } });
await camera.switchCamera();
await camera.setCameraEnabled(false); // unpublish and close
// preview: <GravixPreview camera={beauty.camera} />- Open the camera with
GravixRoomCamera, notlocalParticipant.setCameraEnabled: both together open two cameras. Callcamera.dispose()when the screen goes away. - Add
gravixEffectsPack=modelstoandroid/gradle.propertiesto download the effects pack on first use, as in Flutter. await GravixBeautyEffect.licenseStatus()reports the licence state (OK,MISSING,WRONG_PACKAGE,EXPIREDand others).
Licence token
- Free plan: the effects work without a token, with a Gravix Cloud watermark and QR code on the video.
- Paid plans and custom packages: in the console, open the Effects page, register your Android package name and the SHA-256 of its signing certificate, and create a licence token. Pass it as
licenseToken; it removes the watermark. - The token lasts as long as your App ID's package, or 30 days at a time when you pay from your balance. The SDK renews it about once a day, and offline the last token keeps working until it expires. Over your plan's monthly effects-user limit, or with a revoked token, the watermark comes back until the next renewal.
Not using them
The effects add about 13 MB to an Android app. An app that does not use them can strip them with Gradle excludes and two R8 rules. Do not pass a GravixBeautyEffect then; if one is passed anyway, the room opens its normal camera.
// android/app/build.gradle.kts: for an app that does not use beauty effects (about 13 MB)
configurations.all {
exclude(group = "com.gravix", module = "gravix-effects")
exclude(group = "com.google.mediapipe", module = "tasks-vision")
exclude(group = "com.google.ai.edge.litert", module = "litert")
}# android/app/proguard-rules.pro (R8)
-dontwarn com.gravix.effects.**
-dontwarn com.google.mediapipe.**Packages
- Web and React:
gravix-rtcon npm - Flutter:
gravix_rtcon pub.dev - React Native:
gravix-rtc-react-nativeon npm - Android (Kotlin, Java):
com.gravixcloud:gravix-rtc-androidon Maven Central - Token libraries for your server:
gravix-rtc-token(Node),gravix-token-go(Go) andcom.gravixcloud:gravix-token-java(Java). See access tokens.
