Home > Blockchain >  Possible Unhandled Promise Rejection (id:0) | React native firebase google login
Possible Unhandled Promise Rejection (id:0) | React native firebase google login

Time:08-19

So I've been trying to fix this issue for 2 days. I searched everywhere I even followed some YouTube tutorials but can't find a solution. I'm using @react-native-google-signin/google-signin package and this is my code:

import { StatusBar } from 'expo-status-bar';
import React from 'react';
import { StyleSheet, Text, View, Button } from 'react-native';
import { GoogleSignin } from '@react-native-google-signin/google-signin';

GoogleSignin.configure({
  webClientId: 'xxx.apps.googleusercontent.com',
});

export default function App() {
  return (
    <View style={styles.container}>
      <Text>Loginscreen</Text>
      <Button 
      title='Login'
      onPress={googleLogin}/>
      <StatusBar style="auto" />
    </View>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: '#fff',
    alignItems: 'center',
    justifyContent: 'center',
  },
});

function googleLogin() {
  console.log("trying to login")
  onGoogleButtonPress().then(() => console.log('Signed in with Google!'))
}

async function onGoogleButtonPress() {
  // Get the users ID token
  const { idToken } = await GoogleSignin.signIn();

  // Create a Google credential with the token
  const googleCredential = auth.GoogleAuthProvider.credential(idToken);

  // Sign-in the user with the credential
  return auth().signInWithCredential(googleCredential);
}

This is the error I get: Emulator screenshot

Here is the error log in the console :

 WARN  Possible Unhandled Promise Rejection (id: 1):
Error: DEVELOPER_ERROR
promiseMethodWrapper@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.test&modulesOnly=false&runModule=true:23526:45
http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.test&modulesOnly=false&runModule=true:119816:45
generatorResume@[native code]
asyncGeneratorStep@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.test&modulesOnly=false&runModule=true:25076:26
_next@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.test&modulesOnly=false&runModule=true:25098:29
tryCallOne@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.test&modulesOnly=false&runModule=true:30574:16
http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.test&modulesOnly=false&runModule=true:30675:27
http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.test&modulesOnly=false&runModule=true:31754:26
_callTimer@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.test&modulesOnly=false&runModule=true:31654:17
_callReactNativeMicrotasksPass@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.test&modulesOnly=false&runModule=true:31689:17
callReactNativeMicrotasks@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.test&modulesOnly=false&runModule=true:31896:44
__callReactNativeMicrotasks@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.test&modulesOnly=false&runModule=true:24006:46
http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.test&modulesOnly=false&runModule=true:23785:45
__guard@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.test&modulesOnly=false&runModule=true:23989:15
flushedQueue@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.test&modulesOnly=false&runModule=true:23784:21
flushedQueue@[native code]
callFunctionReturnFlushedQueue@[native code]

I am open to ideas. Thanks for help.

CodePudding user response:

So I tried some other stuff and then I decided I would just follow some step by step tutorial like a monkey and it worked. I didn't notice any differences between how I did it before and now but it works so I probably just forgot to copy-paste some lines to build.gradle I guess. Anyways here is the video I followed If anyone is intrested: https://youtu.be/gai4aYcNunc

  • Related