@byldd/expo-google-signin v1.0.10
@byldd/expo-google-signin
This README provides a step-by-step guide to set up Google Sign-In for Expo projects using the @byldd/expo-google-signin package.
Steps
1. Create a New Expo Project
Run the following command to create a new Expo project:
npx create-expo-app@latest2. Prebuild the Project
Run the following command to generate the android and ios directories:
npx expo prebuildThis command creates the necessary native directories for iOS and Android.
3. Update app.json File
Add the following plugins to the app.json file:
"plugins": [
"@react-native-firebase/app",
"@react-native-firebase/auth",
"@react-native-google-signin/google-signin",
[
"expo-build-properties",
{
"ios": {
"useFrameworks": "static"
}
}
]
]4. Create a New Firebase Project
Setup iOS Project
- For the app bundle ID, go to the
app.jsonfile. - Inside the
iossection, copy thebundleIdentifierand use it to configure the iOS app in Firebase. - Note: Do not download
GoogleService-Info.plistat this point to avoid the reverse client ID bug.
- For the app bundle ID, go to the
Setup Android Project
- For the app bundle ID, go to the
app.jsonfile. - Inside the
androidsection, copy thepackageand use it to configure the Android app in Firebase. - Note: Do not download
google-services.jsonat this point to avoid the reverse client ID bug.
- For the app bundle ID, go to the
Generate SHA1 and SHA256 Keys
- Run the following commands to generate the SHA1 and SHA256 keys:
cd android && ./gradlew signingReport - Copy the SHA1 and SHA256 keys of the debug variant.
- Run the following commands to generate the SHA1 and SHA256 keys:
Add SHA Keys to Firebase
- Go to Settings in your Firebase project.
- Add the SHA1 and SHA256 keys under the project settings.
Enable Google Authentication
- In Firebase, go to Authentication.
- Enable the Google provider.
Download Configuration Files
- Download the
GoogleService-Info.plistandgoogle-services.jsonfiles from Firebase. - Place these files in the root folder of your Expo project.
- Download the
Update app.json with File Paths
- Add the path to the
GoogleService-Info.plistfile in theiossection of theapp.jsonfile:"ios": { "googleServicesFile": "./GoogleService-Info.plist" } - Add the path to the
google-services.jsonfile in theandroidsection of theapp.jsonfile:"android": { "googleServicesFile": "./google-services.json" }
- Add the path to the
5. Install Required Packages
Run the following command to install the required npm packages:
npm install @react-native-firebase/app @react-native-firebase/auth @react-native-google-signin/google-signin expo-build-properties @byldd/expo-google-signin6. Prebuild the Project Again
Run the following command to ensure all the configurations are applied:
npx expo prebuild7. Usage Example
Here is an example of how to use the @byldd/expo-google-signin package in your project:
Note: Make sure to pick the client_id with client_type: 3 from your google-services.json file.
import { GoogleSigninService } from "@byldd/expo-google-signin";
const handleGoogleSignin = async (webClientId: string) => {
try {
const user = await GoogleSigninService.googleSignIn(webClientId);
console.log(user);
} catch (error) {
console.warn(error);
}
};With these steps, you should be able to successfully set up Google Sign-In in your React Native project using the @byldd/expo-google-signin package.