Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/204.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
从react native中的android emulator连接到emulator上运行的云函数_Android_Firebase_React Native_Google Cloud Functions_Firebase Tools - Fatal编程技术网

从react native中的android emulator连接到emulator上运行的云函数

从react native中的android emulator连接到emulator上运行的云函数,android,firebase,react-native,google-cloud-functions,firebase-tools,Android,Firebase,React Native,Google Cloud Functions,Firebase Tools,我正在构建一个应用程序,并使用firebase作为后端。我以前在应用程序中使用firebase。我开发了一个登录云功能 exports.login = functions.https.onCall((data, context) => { console.log("data", data); console.log("context", context); return "Login successful"; }

我正在构建一个应用程序,并使用firebase作为后端。我以前在应用程序中使用firebase。我开发了一个登录云功能

exports.login = functions.https.onCall((data, context) => {
   console.log("data", data);
   console.log("context", context);
   return "Login successful";
});
在functions文件夹中运行npm run serve时,我将在控制台中获得这些配置。

此外,我还添加了以下代码,以便从运行应用程序的android仿真器连接到云函数

import functions from "@react-native-firebase/functions"
const [email, setEmail] = useState("");
    const [password, setPassword] = useState("");
    const handleLogin = () => {
        // console.log(email, password);
        functions()
            .useFunctionsEmulator("URL")
            .httpsCallable("login")({ email, password })
            .then((response) => {
                alert(response);
            });
    }
对于URL,我已尝试“http://localhost:5001/“因为它是函数模拟器正在侦听的端口 . 但是在运行应用程序时,我遇到了这个错误 . 我试着查找错误,但没有发现任何相关的错误。任何帮助都将不胜感激

这些是我定义的云函数

exports.helloWorld = functions.https.onRequest((request, response) => {
   functions.logger.info("Hello logs!", { structuredData: true });
   response.send("Hello from Firebase!");
});

exports.signup = functions.https.onRequest((request, response) => {
   console.log("request", request);
   response.send("SignUp successfull");
});

exports.login = functions.https.onCall((data, context) => {
   console.log("data", data);
   console.log("context", context);
   return "SignIn successfull";
});

我终于解决了

const handleLogin = async () => {
        functions().useFunctionsEmulator("http://localhost:5001")
        const response = await functions().httpsCallable("login")({ email, password });
        console.log("response", response);
    }
这是从正在运行的android仿真器在仿真器内本地成功调用云函数所需的全部代码