@applooma/rtc-react-native 0.1.0 → 0.2.1

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