@applooma/rtc-react-native 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. package/README.md +107 -0
  2. package/dist/index.js +8 -29819
  3. package/dist/index.mjs +9 -29815
  4. package/package.json +7 -7
package/README.md ADDED
@@ -0,0 +1,107 @@
1
+ # @applooma/rtc-react-native
2
+
3
+ Real-time voice, video, live streaming and audio rooms for React Native, by
4
+ [AppLooma LLC](https://applooma.dev).
5
+
6
+ Full documentation: **https://docs.applooma.dev/sdk/react-native**
7
+
8
+ ## Install
9
+
10
+ ```bash
11
+ npm install @applooma/rtc-react-native
12
+ cd ios && pod install
13
+ ```
14
+
15
+ The native modules are ordinary dependencies of the package, so autolinking
16
+ picks them up. Rebuild the app afterwards — reloading the JavaScript bundle is
17
+ not enough.
18
+
19
+ React Native 0.73 or newer and React 18 or newer are peer dependencies.
20
+
21
+ ### One call in each native project
22
+
23
+ The audio engine is set up before React Native starts, so it is initialised
24
+ from the host application rather than from JavaScript. Put the call above any
25
+ other React Native initialisation.
26
+
27
+ **Android** — `MainApplication.kt`:
28
+
29
+ ```kotlin
30
+ import com.applooma.rtc.reactnative.AppLoomaRtc
31
+ import com.applooma.rtc.reactnative.audio.AudioType
32
+
33
+ class MainApplication : Application(), ReactApplication {
34
+ override fun onCreate() {
35
+ AppLoomaRtc.setup(this, AudioType.CommunicationAudioType())
36
+ super.onCreate()
37
+ }
38
+ }
39
+ ```
40
+
41
+ **iOS** — `AppDelegate.swift`:
42
+
43
+ ```swift
44
+ import applooma_rtc_native_core
45
+
46
+ AppLoomaRtc.setup()
47
+ ```
48
+
49
+ ### Permissions
50
+
51
+ `Info.plist` needs `NSCameraUsageDescription` and
52
+ `NSMicrophoneUsageDescription`; without them the app terminates the first time
53
+ it opens a device. `AndroidManifest.xml` needs `CAMERA`, `RECORD_AUDIO`,
54
+ `INTERNET` and `MODIFY_AUDIO_SETTINGS`, and Android 6 and later also require
55
+ requesting camera and microphone at runtime before joining.
56
+
57
+ ## Quickstart
58
+
59
+ Tokens come from **your** server. Your API secret must never ship inside an
60
+ app — anyone who extracts it can issue unlimited tokens on your account.
61
+
62
+ ```tsx
63
+ import { initAppLooma, useAppEngine, AppVideoView } from '@applooma/rtc-react-native';
64
+
65
+ initAppLooma(); // once, at the top of your entry file
66
+
67
+ function Call() {
68
+ const { engine, remoteUsers, join } = useAppEngine({ appId: 'YOUR_APP_ID' });
69
+
70
+ useEffect(() => {
71
+ // Your own endpoint, which calls POST https://api.applooma.dev/v1/token
72
+ // server-side with your API key and secret.
73
+ fetchToken('lobby').then((s) => join(s.token, s.wsUrl, { role: 'host', camera: true }));
74
+ }, [join]);
75
+
76
+ return (
77
+ <>
78
+ <AppVideoView engine={engine} local style={{ flex: 1 }} />
79
+ {remoteUsers.map((user) => (
80
+ <AppVideoView key={user.uid} user={user} style={{ flex: 1 }} />
81
+ ))}
82
+ </>
83
+ );
84
+ }
85
+ ```
86
+
87
+ ## Roles
88
+
89
+ The role is fixed by the token your server issues, not by the client.
90
+
91
+ | Role | Publish | Subscribe | Administer the channel |
92
+ |---|---|---|---|
93
+ | `host` | yes | yes | yes |
94
+ | `cohost` | yes | yes | no |
95
+ | `audience` | no | yes | no |
96
+
97
+ Use `audience` for viewers of a live stream. An audience token cannot publish,
98
+ which is what keeps a large broadcast cheap and stable.
99
+
100
+ ## Support
101
+
102
+ - Documentation — https://docs.applooma.dev
103
+ - Email — support@applooma.dev
104
+
105
+ ## Licence
106
+
107
+ MIT. See [LICENSE](LICENSE).