Skip to content

apiko-dev/amazon-ivs-react-native-broadcast

Repository files navigation

Amazon IVS React Native Broadcast

A React Native wrapper for the Amazon IVS iOS and Android broadcast SDKs.

npm version npm MIT Platform - Android Platform - iOS

⚠️ Note that the current module implementation doesn't support full functionality provided by Amazon IVS iOS and Android broadcast SDKs.

⚠️ Apps using amazon-ivs-react-native-broadcast must target iOS 11 and Android 12 (API 31).


👉 Read more about broadcasting to Amazon IVS.

👉 See Amazon IVS streaming configuration guideline.

Installation

$ yarn add amazon-ivs-react-native-broadcast
# --- or ---
$ npm install amazon-ivs-react-native-broadcast
$ cd ios && pod install && cd ..

IVSBroadcastCameraView component

Allows consumers to stream video from an active phone camera.

⚠️ Requirements

An application must request permission to access the user’s camera and microphone. This isn't specific to the component but required for any application that needs access to the cameras and microphones.

iOS

Add NSCameraUsageDescription and NSMicrophoneUsageDescription keys to the Info.plist file:

...
<key>NSCameraUsageDescription</key>
<string>In order to stream your awesome video, allow access to camera please</string>
<key>NSMicrophoneUsageDescription</key>
<string>In order to stream your awesome audio, allow access to microphone please</string>
...

Android

Add CAMERA and RECORD_AUDIO permissions to the AndroidManifest.xml file:

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

⚠️ On devices before SDK version 23, the permissions are automatically granted if they appear in the manifest, so check should always result to true and request should always resolve to PermissionsAndroid.RESULTS.GRANTED, however if your app is installed on a device that runs Android 6.0 or higher, you must request the _dangerous permissions at runtime manually._

Example of requesting Android dangerous permissions at runtime could be found in the ./example/src/index.android.tsx file.

API

Props Type iOS Android
rtmpsUrl string?
streamKey string?
configurationPreset ConfigurationPreset?
videoConfig IVideoConfig?
audioConfig IAudioConfig?
logLevel LogLevel?
sessionLogLevel LogLevel?
cameraPreviewAspectMode CameraPreviewAspectMode?
isCameraPreviewMirrored boolean?
cameraPosition CameraPosition?
isMuted boolean?
Handlers Type iOS Android
onError (errorMessage: string): void?
onBroadcastError (error: IBroadcastSessionError): void?
onIsBroadcastReady (isReady: boolean): void?
onBroadcastAudioStats (audioStats: IAudioStats): void?
onBroadcastStateChanged (stateStatus: StateStatusUnion, metadata?: StateChangedMetadata): void?
onTransmissionStatisticsChanged (transmissionStatistics: ITransmissionStatistics): void?
onAudioSessionInterrupted (): void? 🚫
onAudioSessionResumed (): void? 🚫
onMediaServicesWereLost (): void? 🚫
onMediaServicesWereReset (): void? 🚫
Methods Type iOS Android
start (options?: StartMethodOptions): void
stop (): void

👉 Read more detailed API documentation.

👉 iOS and Android known issues and workarounds.

Usage

A complex usage could be found in the ./example/src/App.tsx file or just go to the ./example folder and read Setting up and running application section how to set up and run the example app to see IVSBroadcastCameraView component in action.


License

MIT

Credits

This project has been built and is maintained thanks to the support from Apiko.

Apiko