首页 > 解决方案 > TypeError:null 不是对象(评估 'OT.setNativeEvents')

问题描述

我正在使用 opentok-react-native 向我的应用程序添加视频通话功能,代码在虚拟 android 设备中运行良好,但是当我尝试在我的物理设备上运行应用程序时,我收到此错误 TypeError: null is not an object(评估'OT.setNativeEvents') 有人可以帮帮我吗。我的代码是

 import React, {Component} from 'react';
import {View} from 'react-native';
import {OT, OTPublisher, OTSession, OTSubscriber} from "opentok-react-native";

    export default class VideoCall extends Component {
    constructor(props) {
   super(props);

    this.publisherProperties = {
      publishAudio: false,
      cameraPosition: 'front'
    };

  this.publisherEventHandlers = {
    streamCreated: event => {
      console.log('Publisher stream created!', event);
    },
    streamDestroyed: event => {
      console.log('Publisher stream destroyed!', event);
    }
    };
   }

  render() {
    return (
         <OTSession apiKey="my api" sessionId="session id " token="token">
      <OTPublisher
        properties={this.publisherProperties}
        eventHandlers={this.publisherEventHandlers}
        style={{ height: 100, width: 100 }}
      />
    </OTSession>
  );
  }
 }

标签: androidreactjsreact-nativeopentokvideocall

解决方案


推荐阅读