类型错误:null不是对象(正在评估'Chat.addListener')

问题描述 投票:0回答:1

我有一个react native项目,在android和iOS上都能正常运行.我之后使用包'react-native-quickblox-sdk v0.5.2-beta'将调用和聊天服务添加到我的项目中。

它在android上运行得非常好,但是当我在iOS上运行它时,加载完所有的bundles后,就在打开应用程序之前,它出现了一个错误。

TypeError: null is not an object (evalating 'Chat.addListener').下面是错误的图片。Error screen

我的podFile。

plugin 'cocoapods-fix-react-native'

platform :ios, '10.0'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'
pod 'Firebase/Core', '~> 6.15.0'
pod 'Firebase/Messaging'

target 'myApp' do

permissions_path = '../node_modules/react-native-permissions/ios'
  # Pods for myApp
  pod 'QuickBlox'
  pod 'Quickblox-WebRTC'
  pod 'RNPermissions', :path => '../node_modules/react-native-permissions'
  pod 'Permission-Camera', :path => "#{permissions_path}/Camera.podspec"
  pod 'Permission-Microphone', :path => "#{permissions_path}/Microphone.podspec"
  pod 'React-CoreModules', :path => '../node_modules/react-native/React/CoreModules'
  pod 'React', :path => '../node_modules/react-native/'
  pod 'React-Core', :path => '../node_modules/react-native/'
  pod 'React-Core/DevSupport', :path => '../node_modules/react-native/'
  pod 'React-Core/RCTWebSocket', :path => '../node_modules/react-native/'
  pod 'FBReactNativeSpec', :path => "../node_modules/react-native/Libraries/FBReactNativeSpec"
  pod 'RCTRequired', :path => "../node_modules/react-native/Libraries/RCTRequired"
  pod 'RCTTypeSafety', :path => "../node_modules/react-native/Libraries/TypeSafety"
  pod 'FBLazyVector', :path => "../node_modules/react-native/Libraries/FBLazyVector"
  pod 'React-RCTActionSheet', :path => '../node_modules/react-native/Libraries/ActionSheetIOS'
  pod 'React-RCTAnimation', :path => '../node_modules/react-native/Libraries/NativeAnimation'
  pod 'React-RCTBlob', :path => '../node_modules/react-native/Libraries/Blob'
  pod 'React-RCTImage', :path => '../node_modules/react-native/Libraries/Image'
  pod 'React-RCTLinking', :path => '../node_modules/react-native/Libraries/LinkingIOS'
  pod 'React-RCTNetwork', :path => '../node_modules/react-native/Libraries/Network'
  pod 'React-RCTSettings', :path => '../node_modules/react-native/Libraries/Settings'
  pod 'React-RCTText', :path => '../node_modules/react-native/Libraries/Text'
  pod 'React-RCTVibration', :path => '../node_modules/react-native/Libraries/Vibration'

  pod 'ReactCommon/jscallinvoker', :path => "../node_modules/react-native/ReactCommon"
  pod 'ReactCommon/turbomodule/core', :path => "../node_modules/react-native/ReactCommon"

  pod 'React-cxxreact', :path => '../node_modules/react-native/ReactCommon/cxxreact'
  pod 'React-jsi', :path => '../node_modules/react-native/ReactCommon/jsi'
  pod 'React-jsiexecutor', :path => '../node_modules/react-native/ReactCommon/jsiexecutor'
  pod 'React-jsinspector', :path => '../node_modules/react-native/ReactCommon/jsinspector'
  pod 'Yoga', :path => '../node_modules/react-native/ReactCommon/yoga', :modular_headers => true
  pod 'DoubleConversion', :podspec => '../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec'
  pod 'glog', :podspec => '../node_modules/react-native/third-party-podspecs/glog.podspec'
  pod 'Folly', :podspec => '../node_modules/react-native/third-party-podspecs/Folly.podspec'


  pod 'CodePush', :path => '../node_modules/react-native-code-push'
  pod 'ReactNativeExceptionHandler', :podspec => '../node_modules/react-native-exception-handler/ReactNativeExceptionHandler.podspec'
  # pod 'RNFirebase', :path => '../node_modules/react-native-firebase/ios'
  pod 'RNCAsyncStorage', :path => '../node_modules/@react-native-community/async-storage'
  # pod 'RNGestureHandler', :podspec => '../node_modules/react-native-gesture-handler/RNGestureHandler.podspec'
  pod 'react-native-video', :path => '../node_modules/react-native-video/react-native-video.podspec'


  pod 'RNDeviceInfo', :path => '../node_modules/react-native-device-info'
  pod 'RNGestureHandler', :path => '../node_modules/react-native-gesture-handler'
  pod 'RNVectorIcons', :path => '../node_modules/react-native-vector-icons'
  pod 'react-native-orientation-locker', :path => '../node_modules/react-native-orientation-locker'
  pod 'RNBootSplash', :path => '../node_modules/react-native-bootsplash'
  pod 'lottie-react-native', :path => '../node_modules/lottie-react-native'

  pod 'lottie-ios', :path => '../node_modules/lottie-ios'

  # pod 'RNCPushNotificationIOS', :path => '../node_modules/@react-native-community/push-notification-ios'

end

我添加和删除了很多东西 (比如顶部的 quickblox pods),我还修改了'node_modulesquickblox-react-native-sdk'中的一些代码来让它工作,但问题依然存在。

在地址中。{PROJECT_DIRECTORY}/node_modules/quickblox-react-native-sdk/index.js 有一个对象,似乎它返回null或未定义。 这是代码:

the sdk code

改变 Chat.addListenerChat && Chat.addListener 抛出另一个带有这个标题的TypeError。..... (evaluating 'Chat.removeEventListeners') 等等...

任何帮助或解决方案将非常感激。

ios react-native quickblox
1个回答
0
投票

挣扎了2天后,我找到了解决办法。

原来问题出在iOS的链接上。"QuickBlox"& "Quickblox-WebRTC "这两个pod在podfile中是不需要的(后来我加进去想看看是否能用,但没有用)。

而我却将 "quickblox-react-native-sdk "与iOS用rnpm链接起来。

所以这就是方法。

1- 在bash上执行这个命令:

react-native link quickblox-react-native-sdk --platforms ios

2- 写 pod install 命令中 {project-folder}/ios 之后在 bash 上安装 quickblox sdk pod。

再次运行项目,现在 "quickblox-react-native-sdk "在iOS上可以完美运行。

© www.soinside.com 2019 - 2024. All rights reserved.