【问题标题】:What's wrong with my code? My React Native App crashes on calling firestore without any log我的代码有什么问题?我的 React Native App 在没有任何日志的情况下调用 firestore 时崩溃
【发布时间】:2021-12-03 20:40:14
【问题描述】:

这是我的实现,我将 baseURL 存储在我的 firestore 数据库中。我曾经匿名登录以获取网址。但是在调用 firestore 时,我的应用程序崩溃而没有任何错误、警告等。

import {create} from 'apisauce';
import auth from '@react-native-firebase/auth';
import firestore, {firebase} from '@react-native-firebase/firestore';

const apiClient = create({
  method: 'POST',
});

apiClient.addAsyncRequestTransform(async request => {
  await auth()
    .signInAnonymously()
    .then(() => {
      console.log('success');
    })
    .catch(error => {
      console.log(error);
    });
  const url = await firestore()
    .collection('service_url')
    .doc('service_url')
    .get()
    .then(document => console.log(document.data))
    .catch(error => console.log(error));
  console.log(url);
  request.baseURL = url;
  auth().signOut();
});

export default apiClient;

【问题讨论】:

  • 在执行“adb logcat”时,我看到一些日志说类似 FATAL EXCEPTION: grpc-okhttp-0 java.lang.AssertionError: Method getAlpnSelectedProtocol not supported for object SSL socket over Socket[address=firestore. googleapis.com/

标签: javascript firebase react-native google-cloud-firestore firebase-authentication


【解决方案1】:

我遇到的问题是 okHTTP。它不适用于 Android API 30。因此,经过这么多解决方法后,我将 okhttp 依赖项添加到我的项目中。这解决了我的错误。

【讨论】:

    猜你喜欢
    • 2022-11-16
    • 2016-06-17
    • 2014-01-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多