React-Native: TypeError: undefined is not an object

React-Native: TypeError: undefined is not an object

N.B。第一次发帖,请不要犹豫,更正格式错误,问题形式等。

我对 react-native 比较陌生,但我正在尝试构建一个应用程序来使用他们的 API 对 google sheet 进行更改。我找到了一个处理 OAuth 身份验证的包 (repo-linked-here),但它似乎抛出了以下错误:

TypeError: undefined is not an object (evaluating 'Module[fn]')

这是我的大部分 index.android.js:

...
import OAuthManager from 'react-native-oauth';

const manager = new OAuthManager('App');

export default class App extends Component {
  constructor(props){
    super(props);
    this.state = {
      isSignedIn: false
    };
  }
  componentDidMount(){
    manager.configure({
      google: {
        callback_url: 'http://localhost/google',
        client_id: '*************',
        client_secret: '************'
      }
    })
    .then(resp => console.warn(resp))
    .catch(err => console.warn(err));
  }
...

React-native-oauth 似乎表明如果我使用“http://localhost/google”作为回调并在 build.gradle 文件中添加几行,那么 callbacks/linking 应该可以工作很好。

如有任何建议,我们将不胜感激!

我认为你不是从 manager 呼叫 authorize。您也不能将 then & catch 添加到 configure:

componentDidMount(){
  manager.configure({
    google: {
      callback_url: 'http://localhost/google',
      client_id: '*************',
      client_secret: '************'
   }
  });
  manager.authorize('google', {scopes: 'profile email'})
  .then(resp => console.warn(resp))
  .catch(err => console.warn(err));
}

也许其他人遇到了这个问题。 我也收到此错误消息,并花了很多时间寻找任何解决方案,none 个已找到的答案解决了我的问题。 问题既不是 configure 也不是 authorize 。 当您 运行 (cd ios && pod install) 并尝试 link 它要求您覆盖 pods 文件。说是。 我通过 xcode 的 运行ning 应用程序找到了它,然后收到如下错误消息:

framework not found DCTAuth

然后谷歌搜索,发现它与pods文件有关。 希望这会帮助别人。