0

我正在使用 ConnectyCube React Native SDK,但并没有走得太远。当使用它的方法时,我得到并错误地说它们是未定义的,如下所示:TypeError: Cannot read property 'createSession' of undefined。当我 console.logConnectyCube.createSession它记录:

ƒ createSession(params, callback) { this.auth.createSession(params, callback); }.

react-native link connectycube-reactnative我已经使用我在其他帖子上阅读的内容链接了该软件包,但仍然遇到同样的问题。任何人都知道出了什么问题或我该如何解决?提前致谢。

import ConnectyCube from 'connectycube-reactnative'
import config from './ConnectycubeConfig'

export default function App() { 

  console.log(ConnectyCube.createSession)

  var userCredentials = {login: 'xxxxxxxxx', password: 'xxxxxxxx'};

  ConnectyCube.createSession(userCredentials, (error, session) => {

  }); // 'TypeError: Cannot read property 'createSession' of undefined'
4

2 回答 2

1

我不是专家反应。所见即是普遍问题。根据您的错误,它表示“connectyCude”未定义。试试下面的代码。

import {ConnectyCube} from 'connectycube-reactnative'
import config from './ConnectycubeConfig'

export default function App() { 
  var cCube = new ConnectyCube();
  console.log(cCube.createSession)

  var userCredentials = {login: 'xxxxxxxxx', password: 'xxxxxxxx'};

  cCube.createSession(userCredentials, (error, session) => {});
}
于 2019-08-06T14:27:59.343 回答
1

请设置它并proceed使用session.

import ConnectyCube from 'connectycube-reactnative'
...
const cbConfig = [
    {
        appId: 218,
        authKey: 'p-cqm2aatn8ZPM3',
        authSecret: '3hmGuXN8AHZOgg6',
    },
    {
        debug: { mode: 1 },
    },
]
...
  componentWillMount() {
    ConnectyCube.init(...cbConfig)
    ConnectyCube.createSession((failSession, session) => {
      if (!failSession, session) {
       alert("you can get login")
      }
    })
   }
于 2019-08-06T15:10:52.240 回答