物理 IOS/Android 设备上的 Firebase Firestore 模拟器

Firebase Firestore emulator on physical IOS / Android device(物理 IOS/Android 设备上的 Firebase Firestore 模拟器)

本文介绍了物理 IOS/Android 设备上的 Firebase Firestore 模拟器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好的,我已经完成了所有这些研究.

Okay, I'm done with all this research.

我正在尝试让 Firebase - Firestore 数据库模拟器在我开发时通过 Expo 应用程序在我的物理 IOS 设备上工作.

I'm trying to get the Firebase - Firestore database emulator to work on my physical IOS device via the Expo application while I develop.

我可以让 Localhost 在浏览器中工作,并让 10.0.2.2:(8080) 通过 Android 模拟器工作.但是,我无法让我的 PHYSICAL IOS 设备工作.我收到 firebase 无法在 10 秒内连接错误.

I can get Localhost to work in a browser and 10.0.2.2:(8080) to work via Android emulator. However, I cannot get my PHYSICAL IOS device, to work. I get firebase couldn't connect within 10 seconds error.

尝试了localhost,尝试了expo app中提供的ip 192.168.x.x尝试了我当前wifi位置给出的ip地址,没有.

Tried localhost, tried the ip provided in the expo app 192.168.x.x tried the ip address given in my current wifi location, nothing.

我已经对不同的配置进行了广泛的研究.我正在寻找能够让它工作并知道他们的步骤的人.我是否缺少配置设置等?

I've already done EXTENSIVE research into different configuration. I'm looking for someone who has managed to get it to work and know their steps. Am I missing a config setting, etc, etc.

因为它适用于网络,我不相信我有模拟器.

Being that it works in web, emulator I don't believe I have.

我正在使用这段代码来连接Android Emulator/Web browswer

I'm using this piece of code to connect Android Emulator / Web browswer

firebase.firestore().settings({实验力长轮询:真,主机:'10.0.2.2:8084'
,ssl:false})

firebase.firestore().settings({ experimentalForceLongPolling: true, host:'10.0.2.2:8084'
,ssl:false})

请不要在回复中猜测,只寻找那些复制了手头确切问题的解决方案的人.

Please, no guessing in the replies only looking for those who have reproduced the solution to the exact question in hand.

谢谢

推荐答案

在你的 firebase.json 中设置一个主机参数0.0.0.0"适用于您正在使用的每个模拟器.

In your firebase.json set a host parameter of "0.0.0.0" for every emulator you're using.

下面是我用来连接到带有真实 iOS 设备的模拟器的代码

Code I use to connect to the emulator w/ a real iOS device is below

firebase.json

firebase.json

{
  "emulators": {
    "auth": {
      "port": 9099,
      "host": "0.0.0.0"
    },
    "functions": {
      "port": 5001,
      "host": "0.0.0.0"
    },
    "firestore": {
      "port": 8080,
      "host": "0.0.0.0"
    },
    "database": {
      "port": 9000,
      "host": "0.0.0.0"
    },
    "ui": {
      "enabled": true
    }
  },
  "firestore": {
    "rules": "firestore.rules",
    "indexes": "firestore.indexes.json"
  },
  "database": {
    "rules": "database.rules.json"
  }
}

然后在客户端添加

realtimeDatabase.useEmulator(yourLocalIp, 9000);
firestore.useEmulator(yourLocalIp, 8080);
firebase.functions().useEmulator(yourLocalIp, 5001);     
auth.useEmulator('http://yourLocalIp:9099')

这篇关于物理 IOS/Android 设备上的 Firebase Firestore 模拟器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:物理 IOS/Android 设备上的 Firebase Firestore 模拟器

基础教程推荐