React Native IOS-Firebase身份验证网络请求失败

时间:2019-09-01 19:34:07

标签: ios firebase react-native networking request

我已经实现了带有Firebase集成的react native应用。 此处以匿名方式登录用户。

我将本机响应升级到0.60,现在函数signInAnonymously()返回错误“网络请求失败”。 描述:“发生了网络错误(例如超时,连接中断或主机不可达)。”

  • 我已经在Xcode中将“允许任意加载”设置为YES

  • 我已经在iPhone模拟器设置->开发人员->允许HTTP服务中设置

<key>NSAppTransportSecurity</key>
    <dict>
        <key>NSAllowsArbitraryLoads</key>
        <true/>
        <key>NSExceptionDomains</key>
        <dict>
            <key>localhost</key>
            <dict>
                <key>NSExceptionAllowsInsecureHTTPLoads</key>
                <true/>
            </dict>
        </dict>
    </dict>

这是我的firebase.js文件:

import * as firebase from 'firebase';
const settings = {};

// Your web app's Firebase configuration
var firebaseConfig = {
  apiKey: "AIzaSyCg**********eRHumnb_iPpeB3yEA",
  authDomain: "**********.firebaseapp.com",
  databaseURL: "https://*********.firebaseio.com",
  projectId: "*********",
  storageBucket: "**********.appspot.com",
  messagingSenderId: "213******74",
  appId: "1:213******74:web:a******495f2"
};
// Initialize Firebase
firebase.initializeApp(firebaseConfig)
firebase.firestore().settings(settings);

export default firebase;

和我的index.js文件:

import firebase from "./src/service/Firebase"

firebase.auth().signInAnonymously().catch(function (error) {
    console.log(error.code);
    console.log(error.message);
});

这是我的package.json

"dependencies": {
    "@popmotion/popcorn": "^0.4.2",
    "@react-native-community/async-storage": "^1.6.1",
    "@react-native-community/geolocation": "^2.0.2",
    "d3-shape": "^1.3.5",
    "firebase": "^6.5.0",
    "geofirestore": "^3.3.1",
    "native-base": "^2.13.5",
    "randomcolor": "^0.5.4",
    "react": "16.8.6",
    "react-native": "0.60.5",
    "react-native-card-stack-swiper": "^1.1.0",
    "react-native-cardview": "^2.0.3",
    "react-native-easy-grid": "^0.2.2",
    "react-native-elements": "^1.1.0",
    "react-native-firebase": "^5.5.6",
    "react-native-gesture-handler": "^1.4.1",
...
}

在我的Firebase控制台中,用户是匿名登录的,但是仍然会发生错误。

我已经阅读了多个有关类似问题的主题,但是我做了上述所有操作,没有任何帮助。

有人可以帮助我吗?

0 个答案:

没有答案