Expo React-Native EventEmitter.removelistener(' url',。):方法已被弃用。请改用返回的订阅中使用remove()

发布于 2025-02-14 02:03:52 字数 1768 浏览 0 评论 0 原文

我已经搜索了一段时间,但我没有找到任何解决方案。

我正在使用Expo开发一个反应生态应用程序,并且正在使用Firebase使用Googlesignin和WebBrowser进行身份验证。

每当我使用Google签名时,我都会在Android上发出警告。

有什么想法如何删除此警告?

eventemitter.removelistener('url',...):方法已弃用。请改用 remove() eventemitter.addlistener

的订阅中

remove() nofollow noreferrer“> “在此处输入图像描述”

这是处理它的代码:

import { auth } from "../firebase";
import {
Text,
TextInput,
View,
StyleSheet,
TouchableOpacity,
Image,
ScrollView,
} from "react-native";
import { useTranslation } from "react-i18next";
import * as Google from "expo-auth-session/providers/google";
import {
   getAuth,
   GoogleAuthProvider,
   signInWithCredential,
} from "firebase/auth";
import * as WebBrowser from "expo-web-browser";
import { useEffect, useState } from "react";

WebBrowser.maybeCompleteAuthSession();

export default function Login({ navigation }) {
   const [email, setEmail] = useState("");
   const [password, setPassword] = useState("");
   const { t } = useTranslation();

   const [request, response, promptAsync] = Google.useIdTokenAuthRequest({
   expoClientId:"something.apps.googleusercontent.com",
   webClientId:"something.apps.googleusercontent.com",
   clientId:"something.apps.googleusercontent.com",
   });

   useEffect(() => {
      if (response?.type === "success") {
      const { id_token } = response.params;
      const auth = getAuth();
      const credential = GoogleAuthProvider.credential(id_token);
      signInWithCredential(auth, credential);
      navigation.navigate("ShowList");
      }
   }, [response]);

I have been searching for a while now and i haven't found any solution.

I'm developing a react-native application with Expo and i'm using firebase for authentification with GoogleSignIn and WebBrowser.

I have this warning on Android everytime I sign in using Google.

Any ideas how to remove this warning ?

EventEmitter.removeListener('url', ...): Method has been deprecated. Please instead use remove() on the subscription returned by EventEmitter.addListener

enter image description here

This is the code that handles it:

import { auth } from "../firebase";
import {
Text,
TextInput,
View,
StyleSheet,
TouchableOpacity,
Image,
ScrollView,
} from "react-native";
import { useTranslation } from "react-i18next";
import * as Google from "expo-auth-session/providers/google";
import {
   getAuth,
   GoogleAuthProvider,
   signInWithCredential,
} from "firebase/auth";
import * as WebBrowser from "expo-web-browser";
import { useEffect, useState } from "react";

WebBrowser.maybeCompleteAuthSession();

export default function Login({ navigation }) {
   const [email, setEmail] = useState("");
   const [password, setPassword] = useState("");
   const { t } = useTranslation();

   const [request, response, promptAsync] = Google.useIdTokenAuthRequest({
   expoClientId:"something.apps.googleusercontent.com",
   webClientId:"something.apps.googleusercontent.com",
   clientId:"something.apps.googleusercontent.com",
   });

   useEffect(() => {
      if (response?.type === "success") {
      const { id_token } = response.params;
      const auth = getAuth();
      const credential = GoogleAuthProvider.credential(id_token);
      signInWithCredential(auth, credential);
      navigation.navigate("ShowList");
      }
   }, [response]);

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文