google signIn with react native firebase
1: first of all create project in firebase console
2:choose Android
3:add android pakage name from
android/app/src/main /android manifest.xml0
4:copy pakage name and paste into firebase
5:then skip other and click on register app
6:then click next
7:then copy classpath 'com.google.gms:google-services:4.3.10'
and paste into android/build.gradle in dependencies
8:then copy apply plugin: 'com.google.gms.google-services' and paste into app/build.gradle in last
9:then copy this dependenci implementation platform('com.google.firebase:firebase-bom:29.1.0')
and paste into app/build.gradle dependencies
10:then click next button then click continue to console
11:then go to firebase project settings
12:then Add SHA key fingerprints just run this command cd android then run this command ./gradlew signingReport into terminal to generate SHA key and copy it then paste it into firebase certificate fingerprint
then copy SHA256 key and past it into firebase certificate fingerprint SHA 256
13:then download google-servies.json file from firebase and past it into Android/App folder
14:then install RNfirebase pakage for react native
npm install --save @react-native-firebase/app
npm add @react-native-firebase/auth
import { GoogleSignin } from '@react-native-google-signin/google-signin';
GoogleSignin.configure({
webClientId: '',
});
import { GoogleSignin, GoogleSigninButton } from '@react-native-google-signin/google-signin'; <GoogleSigninButton style={{ width: 192, height: 48 }} size={GoogleSigninButton.Size.Wide} color={GoogleSigninButton.Color.Dark} onPress={this._signIn} disabled={this.state.isSigninInProgress} />;
24:we can use signOut methods like this
const signOut = async () => { try { await GoogleSignin.signOut().then(()=>{ alert("successfully singout") }) // alert('successfully signOut'); // this.setState({ user: null }); // Remember to remove the user from your app's state as well } catch (error) { console.error(error); } }; // getaccestoken(); useEffect(() => { getaccestoken() }, []);
Comments
Post a Comment