简体   繁体   English

RtcEngine.init 在本机反应中不起作用

[英]RtcEngine.init is not working in react Native

I am working a project of Video Calling using React Native Agora library.我正在使用 React Native Agora 库进行视频通话项目。 But when I run application I face this error "typeErro: undefined is not object ReactNativeAgora RtcEngine.init(config)但是当我运行应用程序时,我遇到了这个错误“typeErro: undefined is not object ReactNativeAgora RtcEngine.init(config)

RN version: 0.62.2 react-native-agora": "^3.2.2 RN 版本:0.62.2 react-native-agora": "^3.2.2

my Code is我的代码是

import { View, StyleSheet, NativeModules, Platform } from 'react-native';
import { RtcEngine, AgoraView } from 'react-native-agora';
import Icon from 'react-native-vector-icons/MaterialIcons';
import { Actions } from 'react-native-router-flux';
import { configureFonts } from 'react-native-paper';

const  Agora  = NativeModules;                  //Define Agora object as a native module

const {
    FPS30,
    AudioProfileDefault,
    AudioScenarioDefault,
    Adaptative,
} = Agora;                                        //Set defaults for Stream

class Video extends Component {
    constructor(props) {
        super(props);
        this.state = {
            peerIds: [],                                //Array for storing connected peers
            uid: Math.floor(Math.random() * 100),       
            appid: this.props.AppID,                  
            channelName: this.props.ChannelName,        
            vidMute: false,                            
            audMute: false,                             
            joinSucceed: false,                         
        };
        if (Platform.OS === 'android') {
            const Config = {                           
                appid: this.state.appid,                  
                channelProfile: 0,                       
                mode: 1,
                videoEncoderConfig: {                     
                    width: 720,
                    height: 1080,
                    bitrate: 1,
                    frameRate: FPS30,
                    orientationMode: Adaptative,
                },
                audioProfile: AudioProfileDefault,
                audioScenario: AudioScenarioDefault,
            };
                  RtcEngine   //Initialize the RTC engine
        }
    }```

Have a try by running again project by npx react-native run-android command.尝试通过 npx react-native run-android 命令再次运行项目。

If you are using the iOS Device then:如果您使用的是iOS设备,则:

  • cd ios && pod install cd ios && 吊舱安装
  • npx react-native run-ios npx react-native 运行-ios

if still not works try installing the npm package again and follow the documentation.如果仍然不起作用,请尝试再次安装 npm package 并按照文档进行操作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM