├── .watchmanconfig ├── .gitattributes ├── android ├── app │ ├── libs │ │ └── PLACEHOLDER │ ├── src │ │ └── main │ │ │ ├── jniLibs │ │ │ ├── arm64-v8a │ │ │ │ └── PLACEHOLDER │ │ │ └── armeabi-v7a │ │ │ │ └── PLACEHOLDER │ │ │ ├── res │ │ │ ├── values │ │ │ │ ├── strings.xml │ │ │ │ └── styles.xml │ │ │ ├── mipmap-hdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-mdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xhdpi │ │ │ │ └── ic_launcher.png │ │ │ └── mipmap-xxhdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── java │ │ │ └── com │ │ │ │ └── rnapi │ │ │ │ ├── MainActivity.java │ │ │ │ ├── AgoraPackage.java │ │ │ │ ├── MainApplication.java │ │ │ │ ├── SurfaceViewManager.java │ │ │ │ └── ConvertUtils.java │ │ │ └── AndroidManifest.xml │ ├── BUCK │ ├── proguard-rules.pro │ └── build.gradle ├── settings.gradle ├── .idea │ ├── caches │ │ └── build_file_checksums.ser │ ├── runConfigurations.xml │ └── codeStyles │ │ └── Project.xml ├── keystores │ ├── debug.keystore.properties │ └── BUCK ├── gradle │ └── wrapper │ │ └── gradle-wrapper.properties ├── build.gradle ├── gradle.properties ├── gradlew.bat ├── .gitignore └── gradlew ├── .babelrc ├── app.json ├── ios ├── RNapi │ ├── Images.xcassets │ │ ├── Contents.json │ │ └── AppIcon.appiconset │ │ │ └── Contents.json │ ├── AppDelegate.h │ ├── main.m │ ├── AppDelegate.m │ ├── Info.plist │ └── Base.lproj │ │ └── LaunchScreen.xib ├── RNapi.xcodeproj │ ├── project.xcworkspace │ │ └── contents.xcworkspacedata │ └── xcshareddata │ │ └── xcschemes │ │ ├── RNapi-tvOS.xcscheme │ │ └── RNapi.xcscheme ├── Agora-SDK-For-React-Native-API │ ├── AgroaEnumConvert.h │ ├── AgoraRtcEngineModule+EnumConvert.h │ ├── AgoraRtcEngineModule.h │ ├── AgoraViewManager.h │ ├── AgoraViewManager.m │ ├── AgoraEnum.h │ ├── AgoraRtcEngineModule+EnumConvert.m │ ├── AgroaEnumConvert.m │ ├── AgoraNotify.h │ ├── AgoraEnum.m │ └── AgoraRtcEngineModule.m ├── RNapi-tvOSTests │ └── Info.plist └── RNapi-tvOS │ └── Info.plist ├── index.js ├── .buckconfig ├── __tests__ └── App.js ├── package.json ├── components ├── AgoraRendererView.js └── AgoraRtcEngineModule.js ├── LICENSE.md ├── .vscode └── launch.json ├── contributions.md ├── .flowconfig ├── README.zh.md ├── README.md ├── .gitignore ├── App.js ├── guide.md └── apis.md /.watchmanconfig: -------------------------------------------------------------------------------- 1 | {} -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | *.pbxproj -text 2 | -------------------------------------------------------------------------------- /android/app/libs/PLACEHOLDER: -------------------------------------------------------------------------------- 1 | agora-rtc-sdk.jar -------------------------------------------------------------------------------- /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": ["react-native"] 3 | } 4 | -------------------------------------------------------------------------------- /app.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "RNapi", 3 | "displayName": "RNapi" 4 | } -------------------------------------------------------------------------------- /android/app/src/main/jniLibs/arm64-v8a/PLACEHOLDER: -------------------------------------------------------------------------------- 1 | libagora-rtc-sdk-jni.so -------------------------------------------------------------------------------- /android/app/src/main/jniLibs/armeabi-v7a/PLACEHOLDER: -------------------------------------------------------------------------------- 1 | libagora-rtc-sdk-jni.so -------------------------------------------------------------------------------- /android/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'RNapi' 2 | 3 | include ':app' 4 | -------------------------------------------------------------------------------- /android/app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | RNapi 3 | 4 | -------------------------------------------------------------------------------- /ios/RNapi/Images.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | import { AppRegistry } from 'react-native'; 2 | import App from './App'; 3 | 4 | AppRegistry.registerComponent('RNapi', () => App); 5 | -------------------------------------------------------------------------------- /.buckconfig: -------------------------------------------------------------------------------- 1 | 2 | [android] 3 | target = Google Inc.:Google APIs:23 4 | 5 | [maven_repositories] 6 | central = https://repo1.maven.org/maven2 7 | -------------------------------------------------------------------------------- /android/.idea/caches/build_file_checksums.ser: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AgoraIO/React-Native-SDK/HEAD/android/.idea/caches/build_file_checksums.ser -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AgoraIO/React-Native-SDK/HEAD/android/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AgoraIO/React-Native-SDK/HEAD/android/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AgoraIO/React-Native-SDK/HEAD/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AgoraIO/React-Native-SDK/HEAD/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/keystores/debug.keystore.properties: -------------------------------------------------------------------------------- 1 | key.store=debug.keystore 2 | key.alias=androiddebugkey 3 | key.store.password=android 4 | key.alias.password=android 5 | -------------------------------------------------------------------------------- /android/keystores/BUCK: -------------------------------------------------------------------------------- 1 | keystore( 2 | name = "debug", 3 | properties = "debug.keystore.properties", 4 | store = "debug.keystore", 5 | visibility = [ 6 | "PUBLIC", 7 | ], 8 | ) 9 | -------------------------------------------------------------------------------- /ios/RNapi.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /android/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | zipStoreBase=GRADLE_USER_HOME 4 | zipStorePath=wrapper/dists 5 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip 6 | -------------------------------------------------------------------------------- /__tests__/App.js: -------------------------------------------------------------------------------- 1 | import 'react-native'; 2 | import React from 'react'; 3 | import App from '../App'; 4 | 5 | // Note: test renderer must be required after react-native. 6 | import renderer from 'react-test-renderer'; 7 | 8 | it('renders correctly', () => { 9 | const tree = renderer.create( 10 | 11 | ); 12 | }); 13 | -------------------------------------------------------------------------------- /ios/Agora-SDK-For-React-Native-API/AgroaEnumConvert.h: -------------------------------------------------------------------------------- 1 | // 2 | // AgroaEnumConvert.h 3 | // RNapi 4 | // 5 | // Created by CavanSu on 26/03/2018. 6 | // Copyright © 2018 Facebook. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AgroaEnumConvert : NSObject 12 | 13 | @end 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /ios/Agora-SDK-For-React-Native-API/AgoraRtcEngineModule+EnumConvert.h: -------------------------------------------------------------------------------- 1 | // 2 | // AgoraRtcEngineModule+EnumConvert.h 3 | // RNapi 4 | // 5 | // Created by CavanSu on 28/03/2018. 6 | // Copyright © 2018 Facebook. All rights reserved. 7 | // 8 | 9 | #import "AgoraRtcEngineModule.h" 10 | 11 | @interface AgoraRtcEngineModule (EnumConvert) 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /ios/Agora-SDK-For-React-Native-API/AgoraRtcEngineModule.h: -------------------------------------------------------------------------------- 1 | // 2 | // AgoraRtcEngineModule.h 3 | // RNapi 4 | // 5 | // Created by CavanSu on 21/03/2018. 6 | // Copyright © 2018 Facebook. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | @interface AgoraRtcEngineModule : RCTEventEmitter 13 | 14 | @end 15 | -------------------------------------------------------------------------------- /ios/Agora-SDK-For-React-Native-API/AgoraViewManager.h: -------------------------------------------------------------------------------- 1 | // 2 | // AgoraViewManager.h 3 | // RNapi 4 | // 5 | // Created by CavanSu on 23/03/2018. 6 | // Copyright © 2018 Facebook. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | @interface AgoraRendererViewManager : RCTViewManager 13 | + (AgoraRendererViewManager *)currentManager; 14 | @end 15 | -------------------------------------------------------------------------------- /android/app/src/main/java/com/rnapi/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.rnapi; 2 | 3 | import com.facebook.react.ReactActivity; 4 | 5 | public class MainActivity extends ReactActivity { 6 | 7 | /** 8 | * Returns the name of the main component registered from JavaScript. 9 | * This is used to schedule rendering of the component. 10 | */ 11 | @Override 12 | protected String getMainComponentName() { 13 | return "RNapi"; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /ios/RNapi/AppDelegate.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * All rights reserved. 4 | * 5 | * This source code is licensed under the BSD-style license found in the 6 | * LICENSE file in the root directory of this source tree. An additional grant 7 | * of patent rights can be found in the PATENTS file in the same directory. 8 | */ 9 | 10 | #import 11 | 12 | @interface AppDelegate : UIResponder 13 | 14 | @property (nonatomic, strong) UIWindow *window; 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "RNapi", 3 | "version": "0.0.1", 4 | "private": true, 5 | "scripts": { 6 | "start": "node node_modules/react-native/local-cli/cli.js start", 7 | "test": "jest" 8 | }, 9 | "dependencies": { 10 | "react": "16.3.0-alpha.1", 11 | "react-native": "0.54.2" 12 | }, 13 | "devDependencies": { 14 | "babel-jest": "22.4.1", 15 | "babel-preset-react-native": "4.0.0", 16 | "jest": "22.4.2", 17 | "react-test-renderer": "16.3.0-alpha.1" 18 | }, 19 | "jest": { 20 | "preset": "react-native" 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /ios/Agora-SDK-For-React-Native-API/AgoraViewManager.m: -------------------------------------------------------------------------------- 1 | // 2 | // AgoraViewManager.m 3 | // RNapi 4 | // 5 | // Created by CavanSu on 23/03/2018. 6 | // Copyright © 2018 Facebook. All rights reserved. 7 | // 8 | 9 | #import "AgoraViewManager.h" 10 | 11 | @implementation AgoraRendererViewManager 12 | RCT_EXPORT_MODULE(); 13 | 14 | static AgoraRendererViewManager *manager; 15 | 16 | + (AgoraRendererViewManager *)currentManager { 17 | return manager; 18 | } 19 | 20 | - (UIView *)view { 21 | manager = self; 22 | return [[UIView alloc] init]; 23 | } 24 | 25 | @end 26 | -------------------------------------------------------------------------------- /ios/RNapi/main.m: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * All rights reserved. 4 | * 5 | * This source code is licensed under the BSD-style license found in the 6 | * LICENSE file in the root directory of this source tree. An additional grant 7 | * of patent rights can be found in the PATENTS file in the same directory. 8 | */ 9 | 10 | #import 11 | 12 | #import "AppDelegate.h" 13 | 14 | int main(int argc, char * argv[]) { 15 | @autoreleasepool { 16 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /android/.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /components/AgoraRendererView.js: -------------------------------------------------------------------------------- 1 | //import React from 'react'; 2 | import PropTypes from 'prop-types' 3 | import {requireNativeComponent, ViewPropTypes} from 'react-native'; 4 | 5 | var iface = { 6 | name: 'AgoraRendererView', 7 | propTypes: { 8 | //src: PropTypes.array, 9 | //borderRadius: PropTypes.number, 10 | //resizeMode: PropTypes.oneOf(['cover', 'contain', 'stretch']), 11 | width: PropTypes.number, 12 | height: PropTypes.number, 13 | ...ViewPropTypes, // include the default view properties 14 | }, 15 | }; 16 | 17 | module.exports = requireNativeComponent('AgoraRendererView', iface); 18 | -------------------------------------------------------------------------------- /android/build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | repositories { 5 | jcenter() 6 | } 7 | dependencies { 8 | classpath 'com.android.tools.build:gradle:2.2.3' 9 | 10 | // NOTE: Do not place your application dependencies here; they belong 11 | // in the individual module build.gradle files 12 | } 13 | } 14 | 15 | allprojects { 16 | repositories { 17 | mavenLocal() 18 | jcenter() 19 | maven { 20 | // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm 21 | url "$rootDir/../node_modules/react-native/android" 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /ios/RNapi-tvOSTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /android/gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m 13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 14 | 15 | # When configured, Gradle will run in incubating parallel mode. 16 | # This option should only be used with decoupled projects. More details, visit 17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 18 | # org.gradle.parallel=true 19 | 20 | android.useDeprecatedNdk=true 21 | -------------------------------------------------------------------------------- /ios/Agora-SDK-For-React-Native-API/AgoraEnum.h: -------------------------------------------------------------------------------- 1 | // 2 | // AgoraEnum.h 3 | // RNapi 4 | // 5 | // Created by CavanSu on 29/03/2018. 6 | // Copyright © 2018 Facebook. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | extern NSDictionary *AgoraChannelProfileDic; 12 | extern NSDictionary *AgoraVideoRenderModeDic; 13 | extern NSDictionary *AgoraAudioProfileDic; 14 | extern NSDictionary *AgoraAudioScenarioDic; 15 | extern NSDictionary *AgoraVideoProfileDic; 16 | extern NSDictionary *AgoraVideoStreamTypeDic; 17 | extern NSDictionary *AgoraVideoMirrorModeDic; 18 | extern NSDictionary *AgoraAudioEqualizationBandFrequencyDic; 19 | extern NSDictionary *AgoraAudioReverbTypeDic; 20 | extern NSDictionary *AgoraAudioRecordingQualityDic; 21 | extern NSDictionary *AgoraClientRoleDic; 22 | extern NSDictionary *AgoraAudioSessionOperationRestrictionDic; 23 | extern NSDictionary *AgoraStreamFallbackOptionsDic; 24 | 25 | @interface AgoraEnum : NSObject 26 | + (void)loadEnums; 27 | @end 28 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | MIT License (MIT) 2 | Copyright (c) 2018 Agora Lab, Inc (http://www.agora.io/) 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 5 | 6 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 7 | 8 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 9 | -------------------------------------------------------------------------------- /ios/RNapi/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "20x20", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "20x20", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "29x29", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "29x29", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "40x40", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "40x40", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "size" : "60x60", 36 | "scale" : "2x" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "size" : "60x60", 41 | "scale" : "3x" 42 | }, 43 | { 44 | "idiom" : "ios-marketing", 45 | "size" : "1024x1024", 46 | "scale" : "1x" 47 | } 48 | ], 49 | "info" : { 50 | "version" : 1, 51 | "author" : "xcode" 52 | } 53 | } -------------------------------------------------------------------------------- /components/AgoraRtcEngineModule.js: -------------------------------------------------------------------------------- 1 | import {NativeModules, findNodeHandle, Platform, UIManager} from 'react-native'; 2 | import AgoraRendererView from './AgoraRendererView' 3 | let AgoraRtcEngine = Object.create(NativeModules.AgoraRtcEngineModule); 4 | 5 | AgoraRtcEngine.setLocalVideoView = (rendererView, renderMode) => { 6 | if (Platform.OS === 'ios') { 7 | AgoraRtcEngine.setLocalView(findNodeHandle(rendererView), renderMode); 8 | } 9 | else { 10 | UIManager.dispatchViewManagerCommand( 11 | findNodeHandle(rendererView), 12 | UIManager.AgoraRendererView.Commands.localVideo, 13 | [0, renderMode] 14 | ); 15 | } 16 | } 17 | 18 | AgoraRtcEngine.setRemoteVideoView = (rendererView, uid, renderMode) => { 19 | if (Platform.OS === 'ios') { 20 | AgoraRtcEngine.setRemoteView(findNodeHandle(rendererView), uid, renderMode); 21 | } 22 | else { 23 | UIManager.dispatchViewManagerCommand( 24 | findNodeHandle(rendererView), 25 | UIManager.AgoraRendererView.Commands.remoteVideo, 26 | [uid, renderMode] 27 | ); 28 | } 29 | } 30 | 31 | module.exports = AgoraRtcEngine; 32 | -------------------------------------------------------------------------------- /android/app/src/main/java/com/rnapi/AgoraPackage.java: -------------------------------------------------------------------------------- 1 | package com.rnapi; 2 | 3 | import com.facebook.react.ReactPackage; 4 | import com.facebook.react.bridge.NativeModule; 5 | import com.facebook.react.bridge.ReactApplicationContext; 6 | import com.facebook.react.uimanager.ViewManager; 7 | 8 | import java.util.ArrayList; 9 | import java.util.Arrays; 10 | import java.util.List; 11 | 12 | public class AgoraPackage implements ReactPackage { 13 | private AgoraModule mModule; 14 | 15 | @Override 16 | public List createNativeModules( 17 | ReactApplicationContext reactContext) { 18 | List modules = new ArrayList<>(); 19 | 20 | if (mModule == null) { 21 | mModule = new AgoraModule(reactContext); 22 | mModule.setAgoraPackage(this); 23 | } 24 | 25 | modules.add(mModule); 26 | return modules; 27 | } 28 | 29 | @Override 30 | public List createViewManagers(ReactApplicationContext reactContext) { 31 | if (mModule == null) { 32 | mModule = new AgoraModule(reactContext); 33 | mModule.setAgoraPackage(this); 34 | } 35 | return Arrays.asList( 36 | new SurfaceViewManager(mModule) 37 | ); 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /android/app/src/main/java/com/rnapi/MainApplication.java: -------------------------------------------------------------------------------- 1 | package com.rnapi; 2 | 3 | import android.app.Application; 4 | 5 | import com.facebook.react.ReactApplication; 6 | import com.facebook.react.ReactNativeHost; 7 | import com.facebook.react.ReactPackage; 8 | import com.facebook.react.shell.MainReactPackage; 9 | import com.facebook.soloader.SoLoader; 10 | 11 | import java.util.Arrays; 12 | import java.util.List; 13 | 14 | public class MainApplication extends Application implements ReactApplication { 15 | 16 | private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) { 17 | @Override 18 | public boolean getUseDeveloperSupport() { 19 | return BuildConfig.DEBUG; 20 | } 21 | 22 | @Override 23 | protected List getPackages() { 24 | return Arrays.asList( 25 | new MainReactPackage(), 26 | new AgoraPackage() 27 | ); 28 | } 29 | 30 | @Override 31 | protected String getJSMainModuleName() { 32 | return "index"; 33 | } 34 | }; 35 | 36 | @Override 37 | public ReactNativeHost getReactNativeHost() { 38 | return mReactNativeHost; 39 | } 40 | 41 | @Override 42 | public void onCreate() { 43 | super.onCreate(); 44 | SoLoader.init(this, /* native exopackage */ false); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /ios/RNapi/AppDelegate.m: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * All rights reserved. 4 | * 5 | * This source code is licensed under the BSD-style license found in the 6 | * LICENSE file in the root directory of this source tree. An additional grant 7 | * of patent rights can be found in the PATENTS file in the same directory. 8 | */ 9 | 10 | #import "AppDelegate.h" 11 | 12 | #import 13 | #import 14 | 15 | @implementation AppDelegate 16 | 17 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 18 | { 19 | NSURL *jsCodeLocation; 20 | 21 | jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil]; 22 | 23 | RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation 24 | moduleName:@"RNapi" 25 | initialProperties:nil 26 | launchOptions:launchOptions]; 27 | rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0f green:1.0f blue:1.0f alpha:1]; 28 | 29 | self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; 30 | UIViewController *rootViewController = [UIViewController new]; 31 | rootViewController.view = rootView; 32 | self.window.rootViewController = rootViewController; 33 | [self.window makeKeyAndVisible]; 34 | return YES; 35 | } 36 | 37 | @end 38 | -------------------------------------------------------------------------------- /android/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 20 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // Use IntelliSense to learn about possible attributes. 3 | // Hover to view descriptions of existing attributes. 4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "name": "Debug Android", 9 | "program": "${workspaceRoot}/.vscode/launchReactNative.js", 10 | "type": "reactnative", 11 | "request": "launch", 12 | "platform": "android", 13 | "sourceMaps": true, 14 | "outDir": "${workspaceRoot}/.vscode/.react" 15 | }, 16 | { 17 | "name": "Debug iOS", 18 | "program": "${workspaceRoot}/.vscode/launchReactNative.js", 19 | "type": "reactnative", 20 | "request": "launch", 21 | "platform": "ios", 22 | "sourceMaps": true, 23 | "outDir": "${workspaceRoot}/.vscode/.react" 24 | }, 25 | { 26 | "name": "Attach to packager", 27 | "program": "${workspaceRoot}/.vscode/launchReactNative.js", 28 | "type": "reactnative", 29 | "request": "attach", 30 | "sourceMaps": true, 31 | "outDir": "${workspaceRoot}/.vscode/.react" 32 | }, 33 | { 34 | "name": "Debug in Exponent", 35 | "program": "${workspaceRoot}/.vscode/launchReactNative.js", 36 | "type": "reactnative", 37 | "request": "launch", 38 | "platform": "exponent", 39 | "sourceMaps": true, 40 | "outDir": "${workspaceRoot}/.vscode/.react" 41 | } 42 | ] 43 | } -------------------------------------------------------------------------------- /contributions.md: -------------------------------------------------------------------------------- 1 | # Contribute to the Agora React Native Wrapper 2 | 3 | This tutorial enables you to generate project files for Android and iOS, enabling you to contribute your own code to the Agora React Native wrapper for [Android](https://docs.agora.io/en/2.2/product/Voice/API%20Reference/communication_android_audio?platform=Android) / [iOS](https://docs.agora.io/en/2.2/product/Voice/API%20Reference/communication_ios_audio?platform=iOS). 4 | 5 | ## Prerequisites 6 | - Agora.io Developer Account 7 | - Node.js 6.9.1+ 8 | - For Android development: 9 | - Android Studio 2.0+ 10 | - A code editor such as Sublime Text 11 | - Physical Android device (Android Simulator is not supported) 12 | 13 | - For iOS development: 14 | - Xcode 8.0+ 15 | - A physical iPhone or iPad device (iOS Simulator is not supported) 16 | 17 | 18 | ## Quick Start 19 | 20 | 1. Open the Terminal app and run the `init` command to generate the project files. 21 | 22 | ``` 23 | react-native init RNProject 24 | ``` 25 | 26 | 2. Create the Agora React Native wrapper for Android or iOS. 27 | 28 | **Android** 29 | ``` 30 | react-native run-android 31 | ``` 32 | 33 | **iOS** 34 | ``` 35 | react-native run-ios 36 | ``` 37 | 38 | For information on how to apply the available API functionality, see [Agora React Native API](apis.md) . 39 | 40 | ## Resources: 41 | 42 | * Agora RTC API for [Android](https://docs.agora.io/en/2.2/product/Voice/API%20Reference/communication_android_audio?platform=Android) / [iOS](https://docs.agora.io/en/2.2/product/Voice/API%20Reference/communication_ios_audio?platform=iOS). 43 | * Complete API documentation is available at the [Document Center](https://docs.agora.io/en/). 44 | -------------------------------------------------------------------------------- /ios/Agora-SDK-For-React-Native-API/AgoraRtcEngineModule+EnumConvert.m: -------------------------------------------------------------------------------- 1 | // 2 | // AgoraRtcEngineModule+EnumConvert.m 3 | // RNapi 4 | // 5 | // Created by CavanSu on 28/03/2018. 6 | // Copyright © 2018 Facebook. All rights reserved. 7 | // 8 | 9 | #import "AgoraRtcEngineModule+EnumConvert.h" 10 | #import 11 | #import "AgoraEnum.h" 12 | 13 | #pragma mark - 14 | 15 | @implementation AgoraRtcEngineModule (EnumConvert) 16 | static NSMutableDictionary *AgoraTotalDic = nil; 17 | 18 | + (void)load { 19 | [AgoraEnum loadEnums]; 20 | 21 | AgoraTotalDic = [NSMutableDictionary dictionaryWithDictionary:AgoraChannelProfileDic]; 22 | [AgoraTotalDic addEntriesFromDictionary:AgoraVideoRenderModeDic]; 23 | [AgoraTotalDic addEntriesFromDictionary:AgoraAudioProfileDic]; 24 | [AgoraTotalDic addEntriesFromDictionary:AgoraAudioScenarioDic]; 25 | [AgoraTotalDic addEntriesFromDictionary:AgoraVideoProfileDic]; 26 | [AgoraTotalDic addEntriesFromDictionary:AgoraVideoStreamTypeDic]; 27 | [AgoraTotalDic addEntriesFromDictionary:AgoraVideoMirrorModeDic]; 28 | 29 | [AgoraTotalDic addEntriesFromDictionary:AgoraAudioEqualizationBandFrequencyDic]; 30 | [AgoraTotalDic addEntriesFromDictionary:AgoraAudioReverbTypeDic]; 31 | [AgoraTotalDic addEntriesFromDictionary:AgoraAudioRecordingQualityDic]; 32 | 33 | [AgoraTotalDic addEntriesFromDictionary:AgoraClientRoleDic]; 34 | [AgoraTotalDic addEntriesFromDictionary:AgoraAudioSessionOperationRestrictionDic]; 35 | [AgoraTotalDic addEntriesFromDictionary:AgoraStreamFallbackOptionsDic]; 36 | } 37 | 38 | - (NSDictionary *)constantsToExport { 39 | return AgoraTotalDic; 40 | }; 41 | 42 | @end 43 | -------------------------------------------------------------------------------- /.flowconfig: -------------------------------------------------------------------------------- 1 | [ignore] 2 | ; We fork some components by platform 3 | .*/*[.]android.js 4 | 5 | ; Ignore "BUCK" generated dirs 6 | /\.buckd/ 7 | 8 | ; Ignore unexpected extra "@providesModule" 9 | .*/node_modules/.*/node_modules/fbjs/.* 10 | 11 | ; Ignore duplicate module providers 12 | ; For RN Apps installed via npm, "Libraries" folder is inside 13 | ; "node_modules/react-native" but in the source repo it is in the root 14 | .*/Libraries/react-native/React.js 15 | 16 | ; Ignore polyfills 17 | .*/Libraries/polyfills/.* 18 | 19 | ; Ignore metro 20 | .*/node_modules/metro/.* 21 | 22 | [include] 23 | 24 | [libs] 25 | node_modules/react-native/Libraries/react-native/react-native-interface.js 26 | node_modules/react-native/flow/ 27 | node_modules/react-native/flow-github/ 28 | 29 | [options] 30 | emoji=true 31 | 32 | module.system=haste 33 | 34 | munge_underscores=true 35 | 36 | module.name_mapper='^[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> 'RelativeImageStub' 37 | 38 | module.file_ext=.js 39 | module.file_ext=.jsx 40 | module.file_ext=.json 41 | module.file_ext=.native.js 42 | 43 | suppress_type=$FlowIssue 44 | suppress_type=$FlowFixMe 45 | suppress_type=$FlowFixMeProps 46 | suppress_type=$FlowFixMeState 47 | 48 | suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\) 49 | suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)?:? #[0-9]+ 50 | suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy 51 | suppress_comment=\\(.\\|\n\\)*\\$FlowExpectedError 52 | 53 | [version] 54 | ^0.65.0 55 | -------------------------------------------------------------------------------- /ios/RNapi-tvOS/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | UIViewControllerBasedStatusBarAppearance 38 | 39 | NSLocationWhenInUseUsageDescription 40 | 41 | NSAppTransportSecurity 42 | 43 | 44 | NSExceptionDomains 45 | 46 | localhost 47 | 48 | NSExceptionAllowsInsecureHTTPLoads 49 | 50 | 51 | 52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /android/app/BUCK: -------------------------------------------------------------------------------- 1 | # To learn about Buck see [Docs](https://buckbuild.com/). 2 | # To run your application with Buck: 3 | # - install Buck 4 | # - `npm start` - to start the packager 5 | # - `cd android` 6 | # - `keytool -genkey -v -keystore keystores/debug.keystore -storepass android -alias androiddebugkey -keypass android -dname "CN=Android Debug,O=Android,C=US"` 7 | # - `./gradlew :app:copyDownloadableDepsToLibs` - make all Gradle compile dependencies available to Buck 8 | # - `buck install -r android/app` - compile, install and run application 9 | # 10 | 11 | lib_deps = [] 12 | 13 | for jarfile in glob(['libs/*.jar']): 14 | name = 'jars__' + jarfile[jarfile.rindex('/') + 1: jarfile.rindex('.jar')] 15 | lib_deps.append(':' + name) 16 | prebuilt_jar( 17 | name = name, 18 | binary_jar = jarfile, 19 | ) 20 | 21 | for aarfile in glob(['libs/*.aar']): 22 | name = 'aars__' + aarfile[aarfile.rindex('/') + 1: aarfile.rindex('.aar')] 23 | lib_deps.append(':' + name) 24 | android_prebuilt_aar( 25 | name = name, 26 | aar = aarfile, 27 | ) 28 | 29 | android_library( 30 | name = "all-libs", 31 | exported_deps = lib_deps, 32 | ) 33 | 34 | android_library( 35 | name = "app-code", 36 | srcs = glob([ 37 | "src/main/java/**/*.java", 38 | ]), 39 | deps = [ 40 | ":all-libs", 41 | ":build_config", 42 | ":res", 43 | ], 44 | ) 45 | 46 | android_build_config( 47 | name = "build_config", 48 | package = "com.rnapi", 49 | ) 50 | 51 | android_resource( 52 | name = "res", 53 | package = "com.rnapi", 54 | res = "src/main/res", 55 | ) 56 | 57 | android_binary( 58 | name = "app", 59 | keystore = "//android/keystores:debug", 60 | manifest = "src/main/AndroidManifest.xml", 61 | package_type = "debug", 62 | deps = [ 63 | ":app-code", 64 | ], 65 | ) 66 | -------------------------------------------------------------------------------- /android/.idea/codeStyles/Project.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 15 | 16 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /ios/RNapi/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleDisplayName 8 | Agora-React-Native 9 | CFBundleExecutable 10 | $(EXECUTABLE_NAME) 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | $(PRODUCT_NAME) 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1 25 | LSApplicationCategoryType 26 | 27 | LSRequiresIPhoneOS 28 | 29 | NSAppTransportSecurity 30 | 31 | NSAllowsArbitraryLoads 32 | 33 | NSExceptionDomains 34 | 35 | localhost 36 | 37 | NSExceptionAllowsInsecureHTTPLoads 38 | 39 | 40 | 41 | 42 | NSCameraUsageDescription 43 | Privacy - Camera Usage Description 44 | NSLocationWhenInUseUsageDescription 45 | 46 | NSMicrophoneUsageDescription 47 | 48 | UILaunchStoryboardName 49 | LaunchScreen 50 | UIRequiredDeviceCapabilities 51 | 52 | armv7 53 | 54 | UISupportedInterfaceOrientations 55 | 56 | UIInterfaceOrientationPortrait 57 | 58 | UISupportedInterfaceOrientations~ipad 59 | 60 | UIInterfaceOrientationPortrait 61 | 62 | UIViewControllerBasedStatusBarAppearance 63 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /README.zh.md: -------------------------------------------------------------------------------- 1 | # Agora-RTC-SDK-for-React-Native(计划废弃) 2 | 3 | *其他语言:[English](README.md)* 4 | 5 | **本仓库已计划废弃,请在[这里](https://github.com/AgoraIO-Community/Agora-RN-Quickstart)参阅最新的示例代码。最新的示例代码主要使用了开源社区维护的[仓库](https://github.com/syanbo/react-native-agora),且该版本支持了npm以及最新的RN集成方式,以后我们会与开源社区持续一起维护新的RN SDK。** 6 | 7 | 这个开源示例项目是 Agora 视频通话 SDK 对于 **[React Native](https://facebook.github.io/react-native/)** 的封装实现。 8 | 9 | 在这个开源项目包含了封装代码以及一个简单的示例程序,示例程序包含了以下功能: 10 | 11 | - 加入通话和离开通话; 12 | - 切换摄像头; 13 | - 外放和听筒切换; 14 | 15 | ## 运行示例程序 16 | 首先在 [Agora.io 注册](https://dashboard.agora.io/cn/signup/) 注册账号,并创建自己的测试项目,获取到 AppID。将 AppID 填写进 App.js 17 | 18 | ``` 19 | AgoraRtcEngine.createEngine('YOUR APP ID'); 20 | ``` 21 | 22 | 假设你的机器上已经安装了 [Node](https://nodejs.org/en/download/) 并且可以使用 `npm` 这样的命令行工具。 23 | 24 | 安装项目所需的依赖模块: 25 | ``` 26 | npm install 27 | ``` 28 | 29 | ### Android 30 | 然后在 [Agora.io SDK](https://www.agora.io/cn/download/) 下载 **视频通话 + 直播 SDK**,解压后将其中的 **libs** 文件夹下的 ***.jar** 复制到本项目的 **android\app\libs** 下,其中的 **libs** 文件夹下的 **arm64-v8a**/**x86**/**armeabi-v7a** 复制到本项目的 **android/app/src/main/jniLibs** 下。 31 | 32 | 最后打开该项目,连接 Android 测试设备,即可运行项目。 33 | 34 | 运行之前需要启动开发服务环境: 35 | ``` 36 | npm start 37 | ``` 38 | 39 | ### iOS 40 | 然后在 [Agora.io SDK](https://www.agora.io/cn/download/) 下载 **视频通话 + 直播 SDK**,解压后将其中的 **libs** 文件夹下的 **AgoraRtcEngineKit.framework** 复制到本项目的 **ios/RNapi** 文件夹下。 41 | 42 | 最后使用 XCode 打开 RNapi.xcodeproj,连接 iPhone/iPad 测试设备,设置有效的开发者签名后即可运行。 43 | 44 | 运行之前需要启动开发服务环境: 45 | ``` 46 | npm start 47 | ``` 48 | 49 | ## 运行环境 50 | 51 | ### Android 52 | * Android Studio 2.0 +/Visual Studio Code/Sublime Text 53 | * Android 真机设备 54 | * 不支持模拟器 55 | 56 | ### iOS 57 | * XCode 8.0 + 58 | * iOS 真机设备 59 | * 不支持模拟器 60 | 61 | ## 联系我们 62 | 63 | - 完整的 API 文档见 [文档中心](https://docs.agora.io/cn/) 64 | - 如果在集成中遇到问题,你可以到 [开发者社区](https://dev.agora.io/cn/) 提问 65 | - 如果有售前咨询问题,可以拨打 400 632 6626,或加入官方Q群 12742516 提问 66 | - 如果需要售后技术支持,你可以在 [Agora Dashboard](https://dashboard.agora.io) 提交工单 67 | - 如果发现了代码的 bug,欢迎提交 [issue](https://github.com/AgoraIO/Agora-RTC-SDK-for-React-Native/issues) 68 | 69 | ## 代码许可 70 | 71 | The MIT License (MIT). 72 | -------------------------------------------------------------------------------- /android/app/src/main/java/com/rnapi/SurfaceViewManager.java: -------------------------------------------------------------------------------- 1 | package com.rnapi; 2 | 3 | import android.util.Log; 4 | import android.view.SurfaceView; 5 | 6 | import com.facebook.react.bridge.ReadableArray; 7 | import com.facebook.react.common.MapBuilder; 8 | import com.facebook.react.uimanager.SimpleViewManager; 9 | import com.facebook.react.uimanager.ThemedReactContext; 10 | 11 | import java.lang.ref.WeakReference; 12 | import java.util.Map; 13 | 14 | import javax.annotation.Nullable; 15 | 16 | import io.agora.rtc.RtcEngine; 17 | 18 | public class SurfaceViewManager extends SimpleViewManager { 19 | public static final String REACT_CLASS = "AgoraRendererView"; 20 | 21 | public static final int COMMAND_SET_LOCAL_VIDEO = 1; 22 | public static final int COMMAND_SET_REMOTE_VIDEO = 2; 23 | 24 | private WeakReference mAgoraModule; 25 | 26 | public SurfaceViewManager(AgoraModule agoraModule) { 27 | mAgoraModule = new WeakReference<>(agoraModule); 28 | } 29 | 30 | @Override 31 | public String getName() { 32 | return REACT_CLASS; 33 | } 34 | 35 | @Override 36 | protected SurfaceView createViewInstance(ThemedReactContext reactContext) { 37 | SurfaceView surfaceView = RtcEngine.CreateRendererView(reactContext); 38 | surfaceView.setZOrderOnTop(true); 39 | surfaceView.setZOrderMediaOverlay(true); 40 | return surfaceView; 41 | } 42 | 43 | @Nullable 44 | @Override 45 | public Map getCommandsMap() { 46 | Log.d("React", " View manager getCommandsMap:"); 47 | return MapBuilder.of( 48 | "localVideo", 49 | COMMAND_SET_LOCAL_VIDEO, 50 | "remoteVideo", 51 | COMMAND_SET_REMOTE_VIDEO); 52 | } 53 | 54 | @Override 55 | public void receiveCommand(SurfaceView root, int commandId, @Nullable ReadableArray args) { 56 | switch (commandId) { 57 | case COMMAND_SET_LOCAL_VIDEO: { 58 | mAgoraModule.get().setupLocalVideo(root, args.getInt(0), args.getInt(1)); 59 | return; 60 | } 61 | case COMMAND_SET_REMOTE_VIDEO: { 62 | mAgoraModule.get().setupRemoteVideo(root, args.getInt(0), args.getInt(1)); 63 | return; 64 | } 65 | 66 | default: 67 | throw new IllegalArgumentException(String.format( 68 | "Unsupported command %d received by %s.", 69 | commandId, 70 | getClass().getSimpleName())); 71 | } 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /android/gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /android/app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /usr/local/Cellar/android-sdk/24.3.3/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | 19 | # Disabling obfuscation is useful if you collect stack traces from production crashes 20 | # (unless you are using a system that supports de-obfuscate the stack traces). 21 | -dontobfuscate 22 | 23 | # React Native 24 | 25 | # Keep our interfaces so they can be used by other ProGuard rules. 26 | # See http://sourceforge.net/p/proguard/bugs/466/ 27 | -keep,allowobfuscation @interface com.facebook.proguard.annotations.DoNotStrip 28 | -keep,allowobfuscation @interface com.facebook.proguard.annotations.KeepGettersAndSetters 29 | -keep,allowobfuscation @interface com.facebook.common.internal.DoNotStrip 30 | 31 | # Do not strip any method/class that is annotated with @DoNotStrip 32 | -keep @com.facebook.proguard.annotations.DoNotStrip class * 33 | -keep @com.facebook.common.internal.DoNotStrip class * 34 | -keepclassmembers class * { 35 | @com.facebook.proguard.annotations.DoNotStrip *; 36 | @com.facebook.common.internal.DoNotStrip *; 37 | } 38 | 39 | -keepclassmembers @com.facebook.proguard.annotations.KeepGettersAndSetters class * { 40 | void set*(***); 41 | *** get*(); 42 | } 43 | 44 | -keep class * extends com.facebook.react.bridge.JavaScriptModule { *; } 45 | -keep class * extends com.facebook.react.bridge.NativeModule { *; } 46 | -keepclassmembers,includedescriptorclasses class * { native ; } 47 | -keepclassmembers class * { @com.facebook.react.uimanager.UIProp ; } 48 | -keepclassmembers class * { @com.facebook.react.uimanager.annotations.ReactProp ; } 49 | -keepclassmembers class * { @com.facebook.react.uimanager.annotations.ReactPropGroup ; } 50 | 51 | -dontwarn com.facebook.react.** 52 | 53 | # TextLayoutBuilder uses a non-public Android constructor within StaticLayout. 54 | # See libs/proxy/src/main/java/com/facebook/fbui/textlayoutbuilder/proxy for details. 55 | -dontwarn android.text.StaticLayout 56 | 57 | # okhttp 58 | 59 | -keepattributes Signature 60 | -keepattributes *Annotation* 61 | -keep class okhttp3.** { *; } 62 | -keep interface okhttp3.** { *; } 63 | -dontwarn okhttp3.** 64 | 65 | # okio 66 | 67 | -keep class sun.misc.Unsafe { *; } 68 | -dontwarn java.nio.file.* 69 | -dontwarn org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement 70 | -dontwarn okio.** 71 | -------------------------------------------------------------------------------- /android/.gitignore: -------------------------------------------------------------------------------- 1 | 2 | # Created by https://www.gitignore.io/api/java,android,androidstudio 3 | 4 | ### Android ### 5 | # Built application files 6 | *.apk 7 | *.ap_ 8 | 9 | # Files for the ART/Dalvik VM 10 | *.dex 11 | 12 | # Java class files 13 | *.class 14 | 15 | # Generated files 16 | bin/ 17 | gen/ 18 | out/ 19 | 20 | # Gradle files 21 | .gradle/ 22 | build/ 23 | 24 | # Local configuration file (sdk path, etc) 25 | local.properties 26 | 27 | # Proguard folder generated by Eclipse 28 | proguard/ 29 | 30 | # Log Files 31 | *.log 32 | 33 | # Android Studio Navigation editor temp files 34 | .navigation/ 35 | 36 | # Android Studio captures folder 37 | captures/ 38 | 39 | # Intellij 40 | *.iml 41 | .idea/workspace.xml 42 | .idea/tasks.xml 43 | .idea/gradle.xml 44 | .idea/dictionaries 45 | .idea/libraries 46 | 47 | # External native build folder generated in Android Studio 2.2 and later 48 | .externalNativeBuild 49 | 50 | # Freeline 51 | freeline.py 52 | freeline/ 53 | freeline_project_description.json 54 | 55 | ### Android Patch ### 56 | gen-external-apklibs 57 | 58 | ### AndroidStudio ### 59 | # Covers files to be ignored for android development using Android Studio. 60 | 61 | # Built application files 62 | 63 | # Files for the ART/Dalvik VM 64 | 65 | # Java class files 66 | 67 | # Generated files 68 | 69 | # Gradle files 70 | .gradle 71 | 72 | # Signing files 73 | .signing/ 74 | 75 | # Local configuration file (sdk path, etc) 76 | 77 | # Proguard folder generated by Eclipse 78 | 79 | # Log Files 80 | 81 | # Android Studio 82 | /*/build/ 83 | /*/local.properties 84 | /*/out 85 | /*/*/build 86 | /*/*/production 87 | *.ipr 88 | *~ 89 | *.swp 90 | 91 | # Android Patch 92 | 93 | # External native build folder generated in Android Studio 2.2 and later 94 | 95 | # NDK 96 | obj/ 97 | 98 | # IntelliJ IDEA 99 | *.iws 100 | /out/ 101 | 102 | # User-specific configurations 103 | .idea/libraries/ 104 | .idea/.name 105 | .idea/compiler.xml 106 | .idea/copyright/profiles_settings.xml 107 | .idea/encodings.xml 108 | .idea/misc.xml 109 | .idea/modules.xml 110 | .idea/scopes/scope_settings.xml 111 | .idea/vcs.xml 112 | .idea/jsLibraryMappings.xml 113 | .idea/datasources.xml 114 | .idea/dataSources.ids 115 | .idea/sqlDataSources.xml 116 | .idea/dynamic.xml 117 | .idea/uiDesigner.xml 118 | 119 | # OS-specific files 120 | .DS_Store 121 | .DS_Store? 122 | ._* 123 | .Spotlight-V100 124 | .Trashes 125 | ehthumbs.db 126 | Thumbs.db 127 | 128 | # Legacy Eclipse project files 129 | .classpath 130 | .project 131 | .cproject 132 | .settings/ 133 | 134 | # Mobile Tools for Java (J2ME) 135 | .mtj.tmp/ 136 | 137 | # Package Files # 138 | *.war 139 | *.ear 140 | 141 | # virtual machine crash logs (Reference: http://www.java.com/en/download/help/error_hotspot.xml) 142 | hs_err_pid* 143 | 144 | ## Plugin-specific files: 145 | 146 | # mpeltonen/sbt-idea plugin 147 | .idea_modules/ 148 | 149 | # JIRA plugin 150 | atlassian-ide-plugin.xml 151 | 152 | # Mongo Explorer plugin 153 | .idea/mongoSettings.xml 154 | 155 | # Crashlytics plugin (for Android Studio and IntelliJ) 156 | com_crashlytics_export_strings.xml 157 | crashlytics.properties 158 | crashlytics-build.properties 159 | fabric.properties 160 | 161 | ### AndroidStudio Patch ### 162 | 163 | !/gradle/wrapper/gradle-wrapper.jar 164 | 165 | ### Java ### 166 | # Compiled class file 167 | 168 | # Log file 169 | 170 | # BlueJ files 171 | *.ctxt 172 | 173 | # Mobile Tools for Java (J2ME) 174 | 175 | # Package Files # 176 | *.jar 177 | *.zip 178 | *.tar.gz 179 | *.rar 180 | 181 | *.so 182 | 183 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 184 | 185 | 186 | # End of https://www.gitignore.io/api/java,android,androidstudio -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Agora RTC SDK for React Native (Deprecated) 2 | 3 | *Read this in other languages: [中文](README.zh.md)* 4 | 5 | **Please refer to [here](https://github.com/AgoraIO-Community/Agora-RN-Quickstart) for a new QuickStart. This repo is about to be deprecated. The new one has NPM support and is more suited to latest React Native development. The new SDK repo is a community one maintained [here](https://github.com/syanbo/react-native-agora)** 6 | 7 | 8 | This tutorial shows you how to quickly start developing requests with the Agora RTC SDK for [React Native](https://facebook.github.io/react-native/) wrapper for [Android](https://docs.agora.io/en/2.2/product/Voice/API%20Reference/communication_android_audio?platform=Android)/[iOS](https://docs.agora.io/en/2.2/product/Voice/API%20Reference/communication_ios_audio?platform=iOS). 9 | 10 | This tutorial demonstrates these basic Agora SDK features: 11 | 12 | - [Render the View](#render-the-view) 13 | - [Join a Channel](#join-a-channel) 14 | - [Leave a Channel](#leave-a-channel) 15 | - [Switch Camera](#switch-camera) 16 | - [Switch Audio Route](#switch-audio-route) 17 | - [Add Event Listener](#add-event-listener) 18 | 19 | ## Prerequisites 20 | - Agora.io Developer Account 21 | - Node.js 6.9.1+ 22 | - For Android development: 23 | - Android Studio 2.0+ 24 | - A code editor such as Sublime Text 25 | - Physical Android device (Android Simulator is not supported) 26 | 27 | - For iOS development: 28 | - Xcode 8.0+ 29 | - A physical iPhone or iPad device (iOS Simulator is not supported) 30 | 31 | ## Quick Start 32 | This section shows you how to prepare and build the Agora React Native wrapper for the sample app. 33 | 34 | ### Create an Account and Obtain an App ID 35 | 36 | 1. Create a developer account at [agora.io](https://dashboard.agora.io/signin/). 37 | 2. In the Agora.io Dashboard that appears, click **Projects** > **Project List** in the left navigation. 38 | 3. Copy the **App ID** from the Dashboard to a text file. You will use this ID later when you launch the app. 39 | 40 | ### Update and Run the Sample Application 41 | 42 | 1. Open the `App.js` file. In the `render()` method, update `YOUR APP ID` with your App ID. 43 | 44 | ``` JavaScript 45 | render() { 46 | 47 | AgoraRtcEngine.createEngine('YOUR APP ID'); 48 | 49 | ... 50 | } 51 | ``` 52 | 53 | 1. Using Terminal or Command Prompt, `cd` to your project directory and enter ` npm install`. This command generates the project files for the Android or iOS sample apps. 54 | 55 | 2. Add the appropriate SDK, connect the device, and run the project as described here: 56 | 57 | **Android** 58 | 59 | Download the [Agora Video SDK](https://www.agora.io/en/download/). 60 | 61 | Un-compress the downloaded SDK package and copy the `libs/agora-rtc-sdk.jar` file into the `android/app/libs` folder. 62 | 63 | Then copy the `libs/arm64-v8a/x86/armeabi-v7a` folder into the `android/app/src/main/jniLibs` folder. 64 | 65 | In Android Studio, open the `android` project folder and connect the Android device. 66 | 67 | Sync and run the project. 68 | 69 | **iOS** 70 | 71 | Download the [Agora Video SDK](https://www.agora.io/en/download/). 72 | 73 | Un-compress the downloaded SDK package and copy the `libs/AograRtcEngineKit.framework` file into the `ios/RNapi` folder. 74 | 75 | Open `RNapi.xcodeproj` and connect your iPhone/iPad device. 76 | 77 | Apply a valid provisioning profile and run the project. 78 | 79 | ## Resources 80 | - A detailed code walkthrough for this sample is available in [Steps to Create this Sample](./guide.md). 81 | * [Agora React Native API Reference](apis.md). 82 | * Complete API documentation is available at the [Document Center](https://docs.agora.io/en/). 83 | * You can file bugs about this sample [here](https://github.com/AgoraIO/Agora-RTC-SDK-for-React-Native/issues). 84 | * Learn how to [contribute code](contributions.md) to the sample project. 85 | 86 | ## License 87 | This software is under the MIT License (MIT). [View the license](LICENSE.md). 88 | -------------------------------------------------------------------------------- /ios/RNapi/Base.lproj/LaunchScreen.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 25 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | # Created by https://www.gitignore.io/api/reactnative 3 | 4 | ### ReactNative ### 5 | # React Native Stack Base 6 | ### ReactNative.Xcode Stack ### 7 | # Xcode 8 | # 9 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 10 | 11 | ## Build generated 12 | build/ 13 | DerivedData/ 14 | 15 | ## Various settings 16 | *.pbxuser 17 | !default.pbxuser 18 | *.mode1v3 19 | !default.mode1v3 20 | *.mode2v3 21 | !default.mode2v3 22 | *.perspectivev3 23 | !default.perspectivev3 24 | xcuserdata/ 25 | 26 | ## Other 27 | *.moved-aside 28 | *.xccheckout 29 | *.xcscmblueprint 30 | 31 | ### ReactNative.Buck Stack ### 32 | buck-out/ 33 | .buckconfig.local 34 | .buckd/ 35 | .buckversion 36 | .fakebuckversion 37 | 38 | ### ReactNative.Linux Stack ### 39 | *~ 40 | 41 | # temporary files which can be created if a process still has a handle open of a deleted file 42 | .fuse_hidden* 43 | 44 | # KDE directory preferences 45 | .directory 46 | 47 | # Linux trash folder which might appear on any partition or disk 48 | .Trash-* 49 | 50 | # .nfs files are created when an open file is removed but is still being accessed 51 | .nfs* 52 | 53 | ### ReactNative.Node Stack ### 54 | # Logs 55 | logs 56 | *.log 57 | npm-debug.log* 58 | yarn-debug.log* 59 | yarn-error.log* 60 | 61 | # Runtime data 62 | pids 63 | *.pid 64 | *.seed 65 | *.pid.lock 66 | 67 | # Directory for instrumented libs generated by jscoverage/JSCover 68 | lib-cov 69 | 70 | # Coverage directory used by tools like istanbul 71 | coverage 72 | 73 | # nyc test coverage 74 | .nyc_output 75 | 76 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 77 | .grunt 78 | 79 | # Bower dependency directory (https://bower.io/) 80 | bower_components 81 | 82 | # node-waf configuration 83 | .lock-wscript 84 | 85 | # Compiled binary addons (http://nodejs.org/api/addons.html) 86 | build/Release 87 | 88 | # Dependency directories 89 | node_modules/ 90 | jspm_packages/ 91 | 92 | # Typescript v1 declaration files 93 | typings/ 94 | 95 | # Optional npm cache directory 96 | .npm 97 | 98 | # Optional eslint cache 99 | .eslintcache 100 | 101 | # Optional REPL history 102 | .node_repl_history 103 | 104 | # Output of 'npm pack' 105 | *.tgz 106 | 107 | # Yarn Integrity file 108 | .yarn-integrity 109 | 110 | # dotenv environment variables file 111 | .env 112 | 113 | 114 | ### ReactNative.Android Stack ### 115 | # Built application files 116 | *.apk 117 | *.ap_ 118 | 119 | # Files for the ART/Dalvik VM 120 | *.dex 121 | 122 | # Java class files 123 | *.class 124 | 125 | # Generated files 126 | bin/ 127 | gen/ 128 | out/ 129 | 130 | # Gradle files 131 | .gradle/ 132 | 133 | # Local configuration file (sdk path, etc) 134 | local.properties 135 | 136 | # Proguard folder generated by Eclipse 137 | proguard/ 138 | 139 | # Log Files 140 | 141 | # Android Studio Navigation editor temp files 142 | .navigation/ 143 | 144 | # Android Studio captures folder 145 | captures/ 146 | 147 | # Intellij 148 | *.iml 149 | .idea/workspace.xml 150 | .idea/tasks.xml 151 | .idea/gradle.xml 152 | .idea/dictionaries 153 | .idea/libraries 154 | 155 | # External native build folder generated in Android Studio 2.2 and later 156 | .externalNativeBuild 157 | 158 | # Freeline 159 | freeline.py 160 | freeline/ 161 | freeline_project_description.json 162 | 163 | ### ReactNative.macOS Stack ### 164 | *.DS_Store 165 | .AppleDouble 166 | .LSOverride 167 | 168 | # Icon must end with two \r 169 | Icon 170 | 171 | 172 | # Thumbnails 173 | ._* 174 | 175 | # Files that might appear in the root of a volume 176 | .DocumentRevisions-V100 177 | .fseventsd 178 | .Spotlight-V100 179 | .TemporaryItems 180 | .Trashes 181 | .VolumeIcon.icns 182 | .com.apple.timemachine.donotpresent 183 | 184 | # Directories potentially created on remote AFP share 185 | .AppleDB 186 | .AppleDesktop 187 | Network Trash Folder 188 | Temporary Items 189 | .apdisk 190 | 191 | ### ReactNative.Gradle Stack ### 192 | .gradle 193 | **/build/ 194 | 195 | # Ignore Gradle GUI config 196 | gradle-app.setting 197 | 198 | # Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored) 199 | !gradle-wrapper.jar 200 | 201 | # Cache of project 202 | .gradletasknamecache 203 | 204 | # # Work around https://youtrack.jetbrains.com/issue/IDEA-116898 205 | # gradle/wrapper/gradle-wrapper.properties 206 | 207 | 208 | # End of https://www.gitignore.io/api/reactnative -------------------------------------------------------------------------------- /ios/Agora-SDK-For-React-Native-API/AgroaEnumConvert.m: -------------------------------------------------------------------------------- 1 | // 2 | // AgroaEnumConvert.m 3 | // RNapi 4 | // 5 | // Created by CavanSu on 26/03/2018. 6 | // Copyright © 2018 Facebook. All rights reserved. 7 | // 8 | 9 | #import "AgroaEnumConvert.h" 10 | #import 11 | #import 12 | #import 13 | #import 14 | #import 15 | #import "AgoraEnum.h" 16 | 17 | #pragma mark - 18 | @implementation RCTConvert (AgoraChannelProfile) 19 | RCT_ENUM_CONVERTER(AgoraChannelProfile, AgoraChannelProfileDic, 20 | AgoraChannelProfileCommunication, integerValue) 21 | - (NSDictionary *)constantsToExport { 22 | return AgoraChannelProfileDic; 23 | }; 24 | @end 25 | 26 | @implementation RCTConvert (AgoraVideoRenderMode) 27 | RCT_ENUM_CONVERTER(AgoraVideoRenderMode, AgoraVideoRenderModeDic, 28 | AgoraVideoRenderModeHidden, integerValue) 29 | - (NSDictionary *)constantsToExport { 30 | return AgoraVideoRenderModeDic; 31 | }; 32 | @end 33 | 34 | @implementation RCTConvert (AgoraAudioProfile) 35 | RCT_ENUM_CONVERTER(AgoraAudioProfile, AgoraAudioProfileDic, 36 | AgoraAudioProfileDefault, integerValue) 37 | - (NSDictionary *)constantsToExport { 38 | return AgoraAudioProfileDic; 39 | }; 40 | @end 41 | 42 | @implementation RCTConvert (AgoraAudioScenario) 43 | RCT_ENUM_CONVERTER(AgoraAudioScenario, AgoraAudioScenarioDic, 44 | AgoraAudioScenarioDefault, integerValue) 45 | - (NSDictionary *)constantsToExport { 46 | return AgoraAudioScenarioDic; 47 | }; 48 | @end 49 | 50 | @implementation RCTConvert (AgoraVideoProfile) 51 | RCT_ENUM_CONVERTER(AgoraVideoProfile, AgoraVideoProfileDic, 52 | AgoraVideoProfileLandscape360P, integerValue) 53 | - (NSDictionary *)constantsToExport { 54 | return AgoraVideoProfileDic; 55 | }; 56 | @end 57 | 58 | @implementation RCTConvert (AgoraVideoStreamType) 59 | RCT_ENUM_CONVERTER(AgoraVideoStreamType, AgoraVideoStreamTypeDic, 60 | AgoraVideoStreamTypeHigh, integerValue) 61 | - (NSDictionary *)constantsToExport { 62 | return AgoraVideoStreamTypeDic; 63 | }; 64 | @end 65 | 66 | @implementation RCTConvert (AgoraVideoMirrorMode) 67 | RCT_ENUM_CONVERTER(AgoraVideoMirrorMode, AgoraVideoMirrorModeDic, 68 | AgoraVideoMirrorModeAuto, integerValue) 69 | - (NSDictionary *)constantsToExport { 70 | return AgoraVideoMirrorModeDic; 71 | }; 72 | @end 73 | 74 | @implementation RCTConvert (AgoraAudioEqualizationBandFrequency) 75 | RCT_ENUM_CONVERTER(AgoraAudioEqualizationBandFrequency, AgoraAudioEqualizationBandFrequencyDic, 76 | AgoraAudioEqualizationBand31, integerValue) 77 | - (NSDictionary *)constantsToExport { 78 | return AgoraAudioEqualizationBandFrequencyDic; 79 | }; 80 | @end 81 | 82 | @implementation RCTConvert (AgoraAudioReverbType) 83 | RCT_ENUM_CONVERTER(AgoraAudioReverbType, AgoraAudioReverbTypeDic, 84 | AgoraAudioReverbDryLevel, integerValue) 85 | - (NSDictionary *)constantsToExport { 86 | return AgoraAudioReverbTypeDic; 87 | }; 88 | @end 89 | 90 | @implementation RCTConvert (AgoraAudioRecordingQuality) 91 | RCT_ENUM_CONVERTER(AgoraAudioRecordingQuality, AgoraAudioRecordingQualityDic, 92 | AgoraAudioRecordingQualityLow, integerValue) 93 | - (NSDictionary *)constantsToExport { 94 | return AgoraAudioRecordingQualityDic; 95 | }; 96 | @end 97 | 98 | @implementation RCTConvert (AgoraClientRole) 99 | RCT_ENUM_CONVERTER(AgoraClientRole, AgoraClientRoleDic, 100 | AgoraClientRoleAudience, integerValue) 101 | - (NSDictionary *)constantsToExport { 102 | return AgoraClientRoleDic; 103 | }; 104 | @end 105 | 106 | @implementation RCTConvert (AgoraAudioSessionOperationRestriction) 107 | RCT_ENUM_CONVERTER(AgoraAudioSessionOperationRestriction, AgoraAudioSessionOperationRestrictionDic, 108 | AgoraAudioSessionOperationRestrictionNone, integerValue) 109 | - (NSDictionary *)constantsToExport { 110 | return AgoraAudioSessionOperationRestrictionDic; 111 | }; 112 | @end 113 | 114 | @implementation RCTConvert (AgoraStreamFallbackOptions) 115 | RCT_ENUM_CONVERTER(AgoraStreamFallbackOptions, AgoraStreamFallbackOptionsDic, 116 | AgoraStreamFallbackOptionDisabled, integerValue) 117 | - (NSDictionary *)constantsToExport { 118 | return AgoraStreamFallbackOptionsDic; 119 | }; 120 | @end 121 | 122 | //AgoraAudioEqualizationBandFrequencyDic 123 | #pragma mark - 124 | @implementation RCTConvert (LoadDictionary) 125 | + (void)load { 126 | [AgoraEnum loadEnums]; 127 | } 128 | @end 129 | 130 | @implementation AgroaEnumConvert 131 | @end 132 | -------------------------------------------------------------------------------- /ios/Agora-SDK-For-React-Native-API/AgoraNotify.h: -------------------------------------------------------------------------------- 1 | // 2 | // AgoraNotify.h 3 | // RNapi 4 | // 5 | // Created by CavanSu on 26/03/2018. 6 | // Copyright © 2018 Facebook. All rights reserved. 7 | // 8 | 9 | #ifndef AgoraNotify_h 10 | #define AgoraNotify_h 11 | 12 | static NSString *const isCameraZoomSupported = @"isCameraZoomSupported"; 13 | static NSString *const isCameraTorchSupported = @"isCameraTorchSupported"; 14 | static NSString *const isCameraFocusPositionInPreviewSupported = @"isCameraFocusPositionInPreviewSupported"; 15 | static NSString *const isCameraAutoFocusFaceModeSupported = @"isCameraAutoFocusFaceModeSupported"; 16 | static NSString *const isSpeakerphoneEnabled = @"isSpeakerphoneEnabled"; 17 | static NSString *const getEffectsVolume = @"getEffectsVolume"; 18 | static NSString *const getAudioMixingDuration = @"getAudioMixingDuration"; 19 | static NSString *const getAudioMixingCurrentPosition = @"getAudioMixingCurrentPosition"; 20 | static NSString *const startEchoTest = @"startEchoTest"; 21 | static NSString *const getCallId = @"getCallId"; 22 | static NSString *const getSdkVersion = @"getSdkVersion"; 23 | 24 | static NSString *const DidOccurWarning = @"DidOccurWarning"; 25 | static NSString *const DidOccurError = @"DidOccurError"; 26 | static NSString *const LocalDidJoinedChannel = @"LocalDidJoinedChannel"; 27 | static NSString *const CurrentDidRejoinChannel = @"CurrentDidRejoinChannel"; 28 | static NSString *const ReportAudioVolumeIndicationOfSpeakers = @"ReportAudioVolumeIndicationOfSpeakers"; 29 | static NSString *const FirstLocalVideoFrame = @"FirstLocalVideoFrame"; 30 | static NSString *const FirstRemoteVideoDecoded = @"FirstRemoteVideoDecoded"; 31 | static NSString *const FirstRemoteVideoFrame = @"FirstRemoteVideoFrame"; 32 | static NSString *const RemoteDidJoinedChannel = @"RemoteDidJoinedChannel"; 33 | static NSString *const RemoteDidOfflineOfUid = @"RemoteDidOfflineOfUid"; 34 | static NSString *const DidAudioMuted = @"DidAudioMuted"; 35 | static NSString *const DidVideoMuted = @"DidVideoMuted"; 36 | static NSString *const DidVideoEnabled = @"DidVideoEnabled"; 37 | static NSString *const LocalVideoStats = @"LocalVideoStats"; 38 | static NSString *const RemoteVideoStats = @"RemoteVideoStats"; 39 | static NSString *const CameraDidReady = @"CameraDidReady"; 40 | static NSString *const VideoDidStop = @"VideoDidStop"; 41 | static NSString *const ConnectionDidLost = @"ConnectionDidLost"; 42 | static NSString *const ConnectionDidInterrupted = @"ConnectionDidInterrupted"; 43 | static NSString *const ConnectionDidBanned = @"ConnectionDidBanned"; 44 | static NSString *const ReportRtcStats = @"ReportRtcStats"; 45 | static NSString *const DidLeaveChannelWithStats = @"DidLeaveChannelWithStats"; 46 | static NSString *const AudioQuality = @"AudioQuality"; 47 | static NSString *const LastmileQuality = @"LastmileQuality"; 48 | static NSString *const NetworkQuality = @"NetworkQuality"; 49 | static NSString *const RequestToken = @"RequestToken"; 50 | static NSString *const LocalAudioMixingDidFinish = @"LocalAudioMixingDidFinish"; 51 | static NSString *const DidAudioEffectFinish = @"DidAudioEffectFinish"; 52 | static NSString *const RemoteAudioMixingDidStart = @"RemoteAudioMixingDidStart"; 53 | static NSString *const RemoteAudioMixingDidFinish = @"RemoteAudioMixingDidFinish"; 54 | static NSString *const ReceiveStreamMessageFromUid = @"ReceiveStreamMessageFromUid"; 55 | static NSString *const DidOccurStreamMessageErrorFromUid = @"DidOccurStreamMessageErrorFromUid"; 56 | static NSString *const ActiveSpeaker = @"ActiveSpeaker"; 57 | static NSString *const CameraFocusDidChangedToRect = @"CameraFocusDidChangedToRect"; 58 | static NSString *const DidAudioRouteChanged = @"DidAudioRouteChanged"; 59 | static NSString *const VideoSizeChanged = @"VideoSizeChanged"; 60 | static NSString *const DidRefreshRecordingServiceStatus = @"DidRefreshRecordingServiceStatus"; 61 | static NSString *const FirstLocalAudioFrame = @"FirstLocalAudioFrame"; 62 | static NSString *const FirstRemoteAudioFrame = @"FirstRemoteAudioFrame"; 63 | static NSString *const DidClientRoleChanged = @"DidClientRoleChanged"; 64 | 65 | static NSString *const DidMicrophoneEnabled = @"DidMicrophoneEnabled"; 66 | static NSString *const DidLocalVideoEnabled = @"DidLocalVideoEnabled"; 67 | static NSString *const RemoteVideoStateChanged = @"RemoteVideoStateChanged"; 68 | static NSString *const DidLocalPublishFallbackToAudioOnly = @"DidLocalPublishFallbackToAudioOnly"; 69 | static NSString *const DidRemoteSubscribeFallbackToAudioOnly = @"DidRemoteSubscribeFallbackToAudioOnly"; 70 | static NSString *const AudioTransportStats = @"AudioTransportStats"; 71 | static NSString *const VideoTransportStats = @"VideoTransportStats"; 72 | static NSString *const StreamPublished = @"StreamPublished"; 73 | static NSString *const StreamUnpublished = @"StreamUnpublished"; 74 | static NSString *const TranscodingUpdated = @"TranscodingUpdated"; 75 | static NSString *const EngineDidLoaded = @"EngineDidLoaded"; 76 | static NSString *const EngineDidStartCall = @"EngineDidStartCall"; 77 | #endif /* AgoraNotify_h */ 78 | -------------------------------------------------------------------------------- /ios/RNapi.xcodeproj/xcshareddata/xcschemes/RNapi-tvOS.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 29 | 35 | 36 | 37 | 43 | 49 | 50 | 51 | 52 | 53 | 58 | 59 | 61 | 67 | 68 | 69 | 70 | 71 | 77 | 78 | 79 | 80 | 81 | 82 | 92 | 94 | 100 | 101 | 102 | 103 | 104 | 105 | 111 | 113 | 119 | 120 | 121 | 122 | 124 | 125 | 128 | 129 | 130 | -------------------------------------------------------------------------------- /ios/RNapi.xcodeproj/xcshareddata/xcschemes/RNapi.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 29 | 35 | 36 | 37 | 43 | 49 | 50 | 51 | 52 | 53 | 59 | 60 | 62 | 68 | 69 | 70 | 71 | 72 | 78 | 79 | 80 | 81 | 82 | 83 | 94 | 96 | 102 | 103 | 104 | 105 | 109 | 110 | 111 | 112 | 113 | 114 | 120 | 122 | 128 | 129 | 130 | 131 | 133 | 134 | 137 | 138 | 139 | -------------------------------------------------------------------------------- /android/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # For Cygwin, ensure paths are in UNIX format before anything is touched. 46 | if $cygwin ; then 47 | [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` 48 | fi 49 | 50 | # Attempt to set APP_HOME 51 | # Resolve links: $0 may be a link 52 | PRG="$0" 53 | # Need this for relative symlinks. 54 | while [ -h "$PRG" ] ; do 55 | ls=`ls -ld "$PRG"` 56 | link=`expr "$ls" : '.*-> \(.*\)$'` 57 | if expr "$link" : '/.*' > /dev/null; then 58 | PRG="$link" 59 | else 60 | PRG=`dirname "$PRG"`"/$link" 61 | fi 62 | done 63 | SAVED="`pwd`" 64 | cd "`dirname \"$PRG\"`/" >&- 65 | APP_HOME="`pwd -P`" 66 | cd "$SAVED" >&- 67 | 68 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 69 | 70 | # Determine the Java command to use to start the JVM. 71 | if [ -n "$JAVA_HOME" ] ; then 72 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 73 | # IBM's JDK on AIX uses strange locations for the executables 74 | JAVACMD="$JAVA_HOME/jre/sh/java" 75 | else 76 | JAVACMD="$JAVA_HOME/bin/java" 77 | fi 78 | if [ ! -x "$JAVACMD" ] ; then 79 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 80 | 81 | Please set the JAVA_HOME variable in your environment to match the 82 | location of your Java installation." 83 | fi 84 | else 85 | JAVACMD="java" 86 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 87 | 88 | Please set the JAVA_HOME variable in your environment to match the 89 | location of your Java installation." 90 | fi 91 | 92 | # Increase the maximum file descriptors if we can. 93 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 94 | MAX_FD_LIMIT=`ulimit -H -n` 95 | if [ $? -eq 0 ] ; then 96 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 97 | MAX_FD="$MAX_FD_LIMIT" 98 | fi 99 | ulimit -n $MAX_FD 100 | if [ $? -ne 0 ] ; then 101 | warn "Could not set maximum file descriptor limit: $MAX_FD" 102 | fi 103 | else 104 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 105 | fi 106 | fi 107 | 108 | # For Darwin, add options to specify how the application appears in the dock 109 | if $darwin; then 110 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 111 | fi 112 | 113 | # For Cygwin, switch paths to Windows format before running java 114 | if $cygwin ; then 115 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 116 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 117 | 118 | # We build the pattern for arguments to be converted via cygpath 119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120 | SEP="" 121 | for dir in $ROOTDIRSRAW ; do 122 | ROOTDIRS="$ROOTDIRS$SEP$dir" 123 | SEP="|" 124 | done 125 | OURCYGPATTERN="(^($ROOTDIRS))" 126 | # Add a user-defined pattern to the cygpath arguments 127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129 | fi 130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 131 | i=0 132 | for arg in "$@" ; do 133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135 | 136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138 | else 139 | eval `echo args$i`="\"$arg\"" 140 | fi 141 | i=$((i+1)) 142 | done 143 | case $i in 144 | (0) set -- ;; 145 | (1) set -- "$args0" ;; 146 | (2) set -- "$args0" "$args1" ;; 147 | (3) set -- "$args0" "$args1" "$args2" ;; 148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154 | esac 155 | fi 156 | 157 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 158 | function splitJvmOpts() { 159 | JVM_OPTS=("$@") 160 | } 161 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 162 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 163 | 164 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 165 | -------------------------------------------------------------------------------- /android/app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: "com.android.application" 2 | 3 | import com.android.build.OutputFile 4 | 5 | /** 6 | * The react.gradle file registers a task for each build variant (e.g. bundleDebugJsAndAssets 7 | * and bundleReleaseJsAndAssets). 8 | * These basically call `react-native bundle` with the correct arguments during the Android build 9 | * cycle. By default, bundleDebugJsAndAssets is skipped, as in debug/dev mode we prefer to load the 10 | * bundle directly from the development server. Below you can see all the possible configurations 11 | * and their defaults. If you decide to add a configuration block, make sure to add it before the 12 | * `apply from: "../../node_modules/react-native/react.gradle"` line. 13 | * 14 | * project.ext.react = [ 15 | * // the name of the generated asset file containing your JS bundle 16 | * bundleAssetName: "index.android.bundle", 17 | * 18 | * // the entry file for bundle generation 19 | * entryFile: "index.android.js", 20 | * 21 | * // whether to bundle JS and assets in debug mode 22 | * bundleInDebug: false, 23 | * 24 | * // whether to bundle JS and assets in release mode 25 | * bundleInRelease: true, 26 | * 27 | * // whether to bundle JS and assets in another build variant (if configured). 28 | * // See http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Variants 29 | * // The configuration property can be in the following formats 30 | * // 'bundleIn${productFlavor}${buildType}' 31 | * // 'bundleIn${buildType}' 32 | * // bundleInFreeDebug: true, 33 | * // bundleInPaidRelease: true, 34 | * // bundleInBeta: true, 35 | * 36 | * // whether to disable dev mode in custom build variants (by default only disabled in release) 37 | * // for example: to disable dev mode in the staging build type (if configured) 38 | * devDisabledInStaging: true, 39 | * // The configuration property can be in the following formats 40 | * // 'devDisabledIn${productFlavor}${buildType}' 41 | * // 'devDisabledIn${buildType}' 42 | * 43 | * // the root of your project, i.e. where "package.json" lives 44 | * root: "../../", 45 | * 46 | * // where to put the JS bundle asset in debug mode 47 | * jsBundleDirDebug: "$buildDir/intermediates/assets/debug", 48 | * 49 | * // where to put the JS bundle asset in release mode 50 | * jsBundleDirRelease: "$buildDir/intermediates/assets/release", 51 | * 52 | * // where to put drawable resources / React Native assets, e.g. the ones you use via 53 | * // require('./image.png')), in debug mode 54 | * resourcesDirDebug: "$buildDir/intermediates/res/merged/debug", 55 | * 56 | * // where to put drawable resources / React Native assets, e.g. the ones you use via 57 | * // require('./image.png')), in release mode 58 | * resourcesDirRelease: "$buildDir/intermediates/res/merged/release", 59 | * 60 | * // by default the gradle tasks are skipped if none of the JS files or assets change; this means 61 | * // that we don't look at files in android/ or ios/ to determine whether the tasks are up to 62 | * // date; if you have any other folders that you want to ignore for performance reasons (gradle 63 | * // indexes the entire tree), add them here. Alternatively, if you have JS files in android/ 64 | * // for example, you might want to remove it from here. 65 | * inputExcludes: ["android/**", "ios/**"], 66 | * 67 | * // override which node gets called and with what additional arguments 68 | * nodeExecutableAndArgs: ["node"], 69 | * 70 | * // supply additional arguments to the packager 71 | * extraPackagerArgs: [] 72 | * ] 73 | */ 74 | 75 | project.ext.react = [ 76 | entryFile: "index.js" 77 | ] 78 | 79 | apply from: "../../node_modules/react-native/react.gradle" 80 | 81 | /** 82 | * Set this to true to create two separate APKs instead of one: 83 | * - An APK that only works on ARM devices 84 | * - An APK that only works on x86 devices 85 | * The advantage is the size of the APK is reduced by about 4MB. 86 | * Upload all the APKs to the Play Store and people will download 87 | * the correct one based on the CPU architecture of their device. 88 | */ 89 | def enableSeparateBuildPerCPUArchitecture = false 90 | 91 | /** 92 | * Run Proguard to shrink the Java bytecode in release builds. 93 | */ 94 | def enableProguardInReleaseBuilds = false 95 | 96 | android { 97 | compileSdkVersion 23 98 | buildToolsVersion "23.0.1" 99 | 100 | defaultConfig { 101 | applicationId "com.rnapi" 102 | minSdkVersion 16 103 | targetSdkVersion 22 104 | versionCode 1 105 | versionName "1.0" 106 | ndk { 107 | abiFilters "armeabi-v7a", "x86" 108 | } 109 | } 110 | splits { 111 | abi { 112 | reset() 113 | enable enableSeparateBuildPerCPUArchitecture 114 | universalApk false // If true, also generate a universal APK 115 | include "armeabi-v7a", "x86" 116 | } 117 | } 118 | buildTypes { 119 | release { 120 | minifyEnabled enableProguardInReleaseBuilds 121 | proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro" 122 | } 123 | } 124 | // applicationVariants are e.g. debug, release 125 | applicationVariants.all { variant -> 126 | variant.outputs.each { output -> 127 | // For each separate APK per architecture, set a unique version code as described here: 128 | // http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits 129 | def versionCodes = ["armeabi-v7a":1, "x86":2] 130 | def abi = output.getFilter(OutputFile.ABI) 131 | if (abi != null) { // null for the universal-debug, universal-release variants 132 | output.versionCodeOverride = 133 | versionCodes.get(abi) * 1048576 + defaultConfig.versionCode 134 | } 135 | } 136 | } 137 | } 138 | 139 | dependencies { 140 | compile fileTree(dir: "libs", include: ["*.jar"]) 141 | compile "com.android.support:appcompat-v7:23.0.1" 142 | compile "com.facebook.react:react-native:+" // From node_modules 143 | compile 'com.google.code.gson:gson:2.8.5' 144 | } 145 | 146 | // Run this once to be able to run the application with BUCK 147 | // puts all compile dependencies into folder libs for BUCK to use 148 | task copyDownloadableDepsToLibs(type: Copy) { 149 | from configurations.compile 150 | into 'libs' 151 | } 152 | -------------------------------------------------------------------------------- /App.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Sample React Native App 3 | * https://github.com/facebook/react-native 4 | * @flow 5 | */ 6 | 7 | import React, { Component } from 'react'; 8 | import { 9 | Platform, 10 | Button, 11 | StyleSheet, 12 | Text, 13 | View, 14 | Image, 15 | findNodeHandle, 16 | NativeEventEmitter, 17 | NativeModules, 18 | UIManager, 19 | DeviceEventEmitter 20 | } from 'react-native'; 21 | import AgoraRtcEngine from './components/AgoraRtcEngineModule' 22 | import AgoraRendererView from './components/AgoraRendererView' 23 | 24 | const agoraKitEmitter = new NativeEventEmitter(AgoraRtcEngine); 25 | var isSpeakerPhone = false; 26 | //provide this url if you want rtmp relevant features 27 | var cdn_url = "YOUR_CDN_URL" 28 | 29 | export default class App extends Component { 30 | state = { 31 | localStream: null, 32 | remoteStreams: [] 33 | } 34 | viewRegistry = {} 35 | listeners = [] 36 | 37 | componentDidMount() { 38 | this.registerCallbacks(); 39 | AgoraRtcEngine.createEngine("YOUR_APP_ID"); 40 | 41 | AgoraRtcEngine.enableVideo(); 42 | AgoraRtcEngine.enableAudio(); 43 | AgoraRtcEngine.setVideoProfileDetail(360, 640, 15, 300); 44 | } 45 | 46 | componentDidUpdate() { 47 | //the view registry could be changed after render update 48 | //resetup remote views here 49 | let remoteStreams = this.state.remoteStreams || []; 50 | for (let i = 0; i < remoteStreams.length; i++) { 51 | let stream = remoteStreams[i]; 52 | let { uid } = stream; 53 | AgoraRtcEngine.setRemoteVideoView(this.viewRegistry[uid], uid, AgoraRtcEngine.AgoraVideoRenderModeFit) 54 | } 55 | } 56 | 57 | // Agora Action 58 | _joinChannel() { 59 | AgoraRtcEngine.setLocalVideoView(this.viewRegistry["local"], AgoraRtcEngine.AgoraVideoRenderModeFit); 60 | AgoraRtcEngine.setChannelProfile(1); 61 | AgoraRtcEngine.setClientRole(1); 62 | AgoraRtcEngine.setVideoProfile(AgoraRtcEngine.AgoraVideoProfileDEFAULT, true); 63 | AgoraRtcEngine.startPreview(); 64 | AgoraRtcEngine.joinChannel(null, "rnchannel01", "React Native for Agora RTC SDK", 0); 65 | } 66 | 67 | _leaveChannel() { 68 | AgoraRtcEngine.stopPreview(); 69 | AgoraRtcEngine.leaveChannel(); 70 | } 71 | 72 | _switchCamera() { 73 | AgoraRtcEngine.switchCamera(); 74 | } 75 | 76 | _switchAudio() { 77 | AgoraRtcEngine.setEnableSpeakerphone(isSpeakerPhone); 78 | isSpeakerPhone = !isSpeakerPhone; 79 | } 80 | 81 | _startPublish() { 82 | AgoraRtcEngine.addPublishStreamUrl(cdn_url, false) 83 | } 84 | 85 | _stopPublish() { 86 | AgoraRtcEngine.removePublishStreamUrl(cdn_url) 87 | } 88 | 89 | render() { 90 | let remoteViews = this.state.remoteStreams.map(stream => { 91 | let { uid } = stream; 92 | return ( 93 | this.viewRegistry[uid] = component} 95 | key={uid} 96 | style={{ width: 360, height: 240 }} 97 | /> 98 | ) 99 | }) 100 | return ( 101 | 102 | 103 | this.viewRegistry["local"] = component} 105 | style={{ width: 360, height: 240 }} 106 | /> 107 | {remoteViews} 108 | 109 |