şimdi bu documenti kullanarak seninle google sign in butonu koyacağız. Original Google sign in
This module exposes

Google Sign-In for Android (legacy). The underlying SDK is deprecated but functional.
Google Sign-In SDK for iOS and macOS (macOS support is only available to sponsors).
imports example
import {
  GoogleSignin,
  GoogleSigninButton,
  statusCodes,
} from '@react-native-google-signin/google-signin';

configure
signature: (options: ConfigureParams) => void

It is mandatory to call this method before attempting to call signIn() and signInSilently(). This method is synchronous, meaning you can call signIn / signInSilently right after it. Typically, you would call configure only once, soon after your app starts. All parameters are optional.

Example usage with default options: you'll get user email and basic profile info.

import { GoogleSignin } from '@react-native-google-signin/google-signin';

GoogleSignin.configure();

An example with all options enumerated:

GoogleSignin.configure({
  webClientId: '<FROM DEVELOPER CONSOLE>', // client ID of type WEB for your server. Required to get the `idToken` on the user object, and for offline access.
  scopes: ['https://www.googleapis.com/auth/drive.readonly'], // what API you want to access on behalf of the user, default is email and profile
  offlineAccess: true, // if you want to access Google API on behalf of the user FROM YOUR SERVER
  hostedDomain: '', // specifies a hosted domain restriction
  forceCodeForRefreshToken: true, // [Android] related to `serverAuthCode`, read the docs link below *.
  accountName: '', // [Android] specifies an account name on the device that should be used
  iosClientId: '<FROM DEVELOPER CONSOLE>', // [iOS] if you want to specify the client ID of type iOS (otherwise, it is taken from GoogleService-Info.plist)
  googleServicePlistPath: '', // [iOS] if you renamed your GoogleService-Info file, new name here, e.g. "GoogleService-Info-Staging"
  openIdRealm: '', // [iOS] The OpenID2 realm of the home web server. This allows Google to include the user's OpenID Identifier in the OpenID Connect ID token.
  profileImageSize: 120, // [iOS] The desired height (and width) of the profile image. Defaults to 120px
});


* forceCodeForRefreshToken docs

signIn
signature: (options: SignInParams) => Promise<SignInResponse>

Prompts a modal to let the user sign in into your application. Resolved promise returns an SignInResponse object. Rejects with an error otherwise.

signIn example
// import statusCodes along with GoogleSignin
import {
  GoogleSignin,
  statusCodes,
} from '@react-native-google-signin/google-signin';

// Somewhere in your code
const signIn = async () => {
  try {
    await GoogleSignin.hasPlayServices();
    const response = await GoogleSignin.signIn();
    if (isSuccessResponse(response)) {
      setState({ userInfo: response.data });
    } else {
      // sign in was cancelled by user
    }
  } catch (error) {
    if (isErrorWithCode(error)) {
      switch (error.code) {
        case statusCodes.IN_PROGRESS:
          // operation (eg. sign in) already in progress
          break;
        case statusCodes.PLAY_SERVICES_NOT_AVAILABLE:
          // Android only, play services not available or outdated
          break;
        default:
        // some other error happened
      }
    } else {
      // an error that's not related to google sign in occurred
    }
  }
};

Utility Functions
tip
There are 4 helper functions available:

isErrorWithCode for processing errors
isSuccessResponse for checking if a response represents a successful operation. Same as checking response.type === 'success'.
isNoSavedCredentialFoundResponse for checking if a response represents no saved credentials case. Same as checking response.type === 'noSavedCredentialFound'.
isCancelledResponse for checking if a response represents user cancellation case. Same as checking response.type === 'cancelled'.
addScopes
signature: (options: AddScopesParams) => Promise<SignInResponse | null>

This method resolves with SignInResponse object or with null if no user is currently logged in.

You may not need this call: you can supply required scopes to the configure call. However, if you want to gain access to more scopes later, use this call.

Example:

const response = await GoogleSignin.addScopes({
  scopes: ['https://www.googleapis.com/auth/user.gender.read'],
});

signInSilently
signature: () => Promise<SignInSilentlyResponse>

May be called e.g. after of your main component mounts. This method returns a Promise that resolves with the SignInSilentlyResponse object and rejects with an error otherwise.

To see how to handle errors read signIn() method

const getCurrentUser = async () => {
  try {
    const response = await GoogleSignin.signInSilently();
    if (isSuccessResponse(response)) {
      setState({ userInfo: response.data });
    } else if (isNoSavedCredentialFoundResponse(response)) {
      // user has not signed in yet
    }
  } catch (error) {
    // handle errror
  }
};

hasPreviousSignIn
signature: () => boolean

This synchronous method may be used to find out whether some user previously signed in.

Note that hasPreviousSignIn() can return true but getCurrentUser() can return null, in which case you can call signInSilently() to recover the user. However, it may happen that calling signInSilently() rejects with an error (e.g. due to a network issue).

const hasPreviousSignIn = async () => {
  const hasPreviousSignIn = GoogleSignin.hasPreviousSignIn();
  setState({ hasPreviousSignIn });
};

getCurrentUser
signature: () => User | null

This is a synchronous method that returns null or User object of the currently signed-in user.

const getCurrentUser = async () => {
  const currentUser = GoogleSignin.getCurrentUser();
  setState({ currentUser });
};

clearCachedAccessToken
signature: (accessTokenString: string) => Promise<null>

This method only has an effect on Android. You may run into a 401 Unauthorized error when a token is invalid. Call this method to remove the token from local cache and then call getTokens() to get fresh tokens. Calling this method on iOS does nothing and always resolves. This is because on iOS, getTokens() always returns valid tokens, refreshing them first if they have expired or are about to expire (see docs).

getTokens
signature: () => Promise<GetTokensResponse>

Resolves with an object containing { idToken: string, accessToken: string, } or rejects with an error. Note that using accessToken for identity assertion on your backend server is discouraged.

signOut
signature: () => Promise<null>

Signs out the current user.

const signOut = async () => {
  try {
    await GoogleSignin.signOut();
    setState({ user: null }); // Remember to remove the user from your app's state as well
  } catch (error) {
    console.error(error);
  }
};


revokeAccess
signature: () => Promise<null>

Removes your application from the user authorized applications. Read more about it here and here.

const revokeAccess = async () => {
  try {
    await GoogleSignin.revokeAccess();
    // Google Account disconnected from your app.
    // Perform clean-up actions, such as deleting data associated with the disconnected account.
  } catch (error) {
    console.error(error);
  }
};


hasPlayServices
signature: (options: HasPlayServicesParams) => Promise<boolean>

Checks if device has Google Play Services installed. Always resolves to true on iOS.

Presence of up-to-date Google Play Services is required to show the sign in modal, but it is not required to perform calls to configure and signInSilently. Therefore, we recommend to call hasPlayServices directly before signIn.

try {
  await GoogleSignin.hasPlayServices({ showPlayServicesUpdateDialog: true });
  // google services are available
} catch (err) {
  console.error('play services are not available');
}

hasPlayServices accepts one parameter, an object which contains a single key: showPlayServicesUpdateDialog (defaults to true). When showPlayServicesUpdateDialog is set to true the library will prompt the user to take action to solve the issue, as seen in the figure below.

You may also use this call at any time to find out if Google Play Services are available and react to the result as necessary. bilgilerim:
// utils/firebase.js

import Constants from 'expo-constants';
import { initializeApp, getApps } from 'firebase/app';
import { getFirestore } from 'firebase/firestore';
import { initializeAuth, getReactNativePersistence } from 'firebase/auth';
import { getStorage } from 'firebase/storage';
import ReactNativeAsyncStorage from '@react-native-async-storage/async-storage';

const { extra } = Constants.expoConfig || {};

// Firebase configuration
const firebaseConfig = {
  apiKey: extra.apiKey,
  authDomain: extra.authDomain,
  projectId: extra.projectId,
  storageBucket: extra.storageBucket,
  messagingSenderId: extra.messagingSenderId,
  appId: extra.appId,
};

// Initialize Firebase
let app;
if (!getApps().length) {
  app = initializeApp(firebaseConfig);
  console.log('Firebase app initialized');
} else {
  app = getApps()[0];
  console.log('Firebase app already initialized');
}

const db = getFirestore(app);
console.log('Firestore initialized');

const auth = initializeAuth(app, {
  persistence: getReactNativePersistence(ReactNativeAsyncStorage),
});
console.log('Auth initialized');

const storage = getStorage(app);
console.log('Storage initialized');

export { db, auth, storage };
// screens/ProfileScreen.js

import React, { useEffect, useState, useCallback } from 'react';
import { Image, View, Text, StyleSheet, TouchableOpacity, Alert, ScrollView } from 'react-native';
import { useNavigation, useFocusEffect } from '@react-navigation/native';
import PropTypes from 'prop-types';
import { useThemeAndLanguage } from '../utils/ThemeAndLanguageContext';
import { auth, db } from '../utils/firebase';
import { doc, getDoc } from 'firebase/firestore';
import AsyncStorage from '@react-native-async-storage/async-storage';
import { useVocabulary } from './VocabularyContext';
import { Ionicons } from '@expo/vector-icons';
// import useGoogleSignIn from '../utils/useGoogleSignIn'; // Google Sign-In import'u kaldırıldı

const ProfileScreen = ({ route }) => {
  const { theme, t, locale } = useThemeAndLanguage();
  const navigation = useNavigation();
  const { logout } = useVocabulary();
  const [isLoggedIn, setIsLoggedIn] = useState(false);
  const [user, setUser] = useState(null);
  const [displayName1, setDisplayName1] = useState('');
  const [catImageUrl, setCatImageUrl] = useState('https://cataas.com/cat?width=300&height=300');
  const [coverImageUrl, setCoverImageUrl] = useState('https://picsum.photos/800/300');

  // const { signInWithGoogle } = useGoogleSignIn(); // signInWithGoogle kullanımı kaldırıldı

  useEffect(() => {
    const unsubscribe = auth.onAuthStateChanged(fetchUserData);
    return () => unsubscribe();
  }, []);

  useFocusEffect(
    useCallback(() => {
      const currentUser = auth.currentUser;
      if (currentUser) {
        fetchUserData(currentUser);
      } else if (route.params?.refresh) {
        fetchUserData();
      }
    }, [route.params?.refresh])
  );

  const fetchUserData = async (currentUser) => {
    if (currentUser) {
      setIsLoggedIn(true);
      setUser(currentUser);

      const userDoc = doc(db, 'users', currentUser.uid);
      const docSnap = await getDoc(userDoc);

      if (docSnap.exists()) {
        setDisplayName1(docSnap.data().displayName1 || '');
        await AsyncStorage.setItem('displayName1', docSnap.data().displayName1 || '');
      } else {
        console.log('No such document!');
      }
    } else {
      setIsLoggedIn(false);
      setUser(null);
      setDisplayName1('');
      await AsyncStorage.removeItem('displayName1');
    }
  };

  const handleLogout = async () => {
    try {
      await auth.signOut();
      await AsyncStorage.clear();
      await logout();
    } catch (error) {
      Alert.alert('Error', error.message);
    }
  };

  const refreshImages = () => {
    const newCatImageUrl = `https://cataas.com/cat?width=300&height=300&timestamp=${new Date().getTime()}`;
    const newCoverImageUrl = `https://picsum.photos/800/300?timestamp=${new Date().getTime()}`;
    setCatImageUrl(newCatImageUrl);
    setCoverImageUrl(newCoverImageUrl);
  };

  return (
    <ScrollView style={[styles.container, { backgroundColor: theme.backgroundColor }]}>
      {isLoggedIn && user ? (
        <View>
          <View style={styles.coverImageContainer}>
            <Image
              source={{ uri: coverImageUrl }}
              style={styles.coverImage}
              resizeMode="cover"
            />
          </View>
          <View style={styles.profileInfo}>
            <Image
              source={{ uri: catImageUrl }}
              style={styles.profileImage}
              resizeMode="cover"
            />
            <Text style={[styles.username, { color: theme.textColor }]}>
              {displayName1 || 'Anonymous User'}
            </Text>
            <Text style={[styles.email, { color: theme.secondaryColor }]}>
              {user.email}
            </Text>
          </View>

          <View style={styles.buttonContainer}>
            <View style={styles.row}>
              <TouchableOpacity
                style={[
                  styles.button,
                  { backgroundColor: theme.primaryColor },
                ]}
                onPress={refreshImages}
              >
                <Ionicons name="refresh" size={20} color={theme.textColor2} style={styles.buttonIcon} />
                <Text style={[styles.buttonTextLoggedIn, { color: theme.textColor2 }]}>
                  {t('refreshImages')}
                </Text>
              </TouchableOpacity>

              <TouchableOpacity
                style={[
                  styles.button,
                  { backgroundColor: theme.primaryColor },
                ]}
                onPress={() => navigation.navigate('Settings')}
              >
                <Ionicons name="settings-outline" size={20} color={theme.textColor2} style={styles.buttonIcon} />
                <Text style={[styles.buttonTextLoggedIn, { color: theme.textColor2 }]}>
                  {t('settings')}
                </Text>
              </TouchableOpacity>
            </View>

            <View style={styles.row}>
              <TouchableOpacity
                style={[
                  styles.button,
                  { backgroundColor: theme.primaryColor },
                ]}
                onPress={() => navigation.navigate('EditProfile')}
              >
                <Ionicons name="create-outline" size={20} color={theme.textColor2} style={styles.buttonIcon} />
                <Text style={[styles.buttonTextLoggedIn, { color: theme.textColor2 }]}>
                  {t('editProfile')}
                </Text>
              </TouchableOpacity>

              <TouchableOpacity
                style={[
                  styles.button,
                  { backgroundColor: theme.primaryColor },
                ]}
                onPress={handleLogout}
              >
                <Ionicons name="log-out-outline" size={20} color={theme.textColor2} style={styles.buttonIcon} />
                <Text style={[styles.buttonTextLoggedIn, { color: theme.textColor2 }]}>
                  {t('logout')}
                </Text>
              </TouchableOpacity>
            </View>
          </View>

          {/* HeartedStories Component */}
          <HeartedStories />
        </View>
      ) : (
        <View style={styles.authContainer}>
          <Image
            source={require('../../assets/kabe.jpg')}
            style={styles.image}
            resizeMode="cover"
          />
          <Text style={[styles.title, { color: theme.textColor }]}>
            {t('loginToYourAccount')}
          </Text>

          <TouchableOpacity
            style={[
              styles.authButton,
              { backgroundColor: theme.primaryColor },
            ]}
            onPress={() => navigation.navigate('Login')}
          >
            <Ionicons name="log-in-outline" size={20} color="white" style={styles.buttonIcon} />
            <Text style={styles.authButtonText}>{t('login')}</Text>
          </TouchableOpacity>
          <TouchableOpacity
            style={[
              styles.authButton,
              { backgroundColor: theme.primaryColor },
            ]}
            onPress={() => navigation.navigate('Register')}
          >
            <Ionicons name="person-add-outline" size={20} color="white" style={styles.buttonIcon} />
            <Text style={styles.authButtonText}>{t('register')}</Text>
          </TouchableOpacity>

          {/* Google Sign-In Button Removed */}
        </View>
      )}
    </ScrollView>
  );
};

ProfileScreen.propTypes = {
  route: PropTypes.object.isRequired,
};

const styles = StyleSheet.create({
  container: {
    flex: 1,
  },
  coverImageContainer: {
    width: '100%',
    height: 200,
  },
  coverImage: {
    width: '100%',
    height: '100%',
  },
  profileInfo: {
    alignItems: 'center',
    marginTop: -75,
    paddingVertical: 10,
  },
  profileImage: {
    width: 150,
    height: 150,
    borderRadius: 75,
    borderWidth: 3,
    borderColor: '#fff',
  },
  username: {
    fontSize: 20,
    fontWeight: 'bold',
    marginTop: 5,
  },
  email: {
    fontSize: 14,
    color: '#888',
    marginTop: 5,
  },
  buttonContainer: {
    paddingHorizontal: 16,
    paddingVertical: 20,
  },
  row: {
    flexDirection: 'row',
    justifyContent: 'space-between',
    marginBottom: 10,
  },
  // Styles for Logged-In Buttons
  button: {
    flexDirection: 'row',
    alignItems: 'center',
    paddingVertical: 10,
    paddingHorizontal: 15,
    borderRadius: 8,
    flex: 1,
    marginHorizontal: 5,
    height: 50,
    fontWeight: 'bold',
  },
  buttonIcon: {
    marginRight: 8,
  },
  buttonTextLoggedIn: {
    fontSize: 16,
  },
  // Styles for Auth (Pre-Login) Buttons
  authContainer: {
    paddingHorizontal: 16,
    paddingVertical: 20,
    marginTop: '30%',
    alignItems: 'center',
    justifyContent: 'center',
  },
  authButton: {
    width: '85%',
    padding: 15,
    borderRadius: 5,
    alignItems: 'center',
    marginTop: 15,
    elevation: 2,
    flexDirection: 'row',
    justifyContent: 'center',
  },
  authButtonText: {
    color: 'white',
    fontSize: 16,
    fontWeight: 'bold',
    marginLeft: 8, // Space between icon and text
  },
  image: {
    width: '85%',
    height: 200,
    borderRadius: 10,
  },
  title: {
    fontSize: 20,
    fontWeight: 'bold',
    marginVertical: 10,
  },
  googleButton: { // Bu stilleri kaldırabilirsiniz ya da gelecek kullanımlar için tutabilirsiniz
    backgroundColor: '#4285F4', // Google Blue
  },
  googleIcon: { // Bu stilleri kaldırabilirsiniz ya da gelecek kullanımlar için tutabilirsiniz
    width: 24,
    height: 24,
  },
});

export default ProfileScreen;

// app.config.js

export default ({ config }) => ({
  ...config,
  scheme: "myapp", // Uygulamanıza özgü benzersiz bir şema ismi seçin
  android: {
    ...config.android,
    googleServicesFile: "./google-services.json", // Android için Firebase yapılandırma dosyasının yolu
  },
  extra: {
    ...config.extra,
    apiKeyGoogle: process.env.API_KEY_GOOGLE,
    apiKey: process.env.FIREBASE_API_KEY,
    authDomain: process.env.FIREBASE_AUTH_DOMAIN,
    projectId: process.env.FIREBASE_PROJECT_ID,
    storageBucket: process.env.FIREBASE_STORAGE_BUCKET,
    messagingSenderId: process.env.FIREBASE_MESSAGING_SENDER_ID,
    appId: process.env.FIREBASE_APP_ID,
    apiKeyVoiceRSS: process.env.apiKeyVoiceRSS,
    type: process.env.FIREBASE_TYPE,
    private_key_id: process.env.FIREBASE_PRIVATE_KEY_ID,
    private_key: process.env.FIREBASE_PRIVATE_KEY,
    client_email: process.env.FIREBASE_CLIENT_EMAIL,
    client_id: process.env.FIREBASE_CLIENT_ID,
    auth_uri: process.env.FIREBASE_AUTH_URI,
    token_uri: process.env.FIREBASE_TOKEN_URI,
    auth_provider_x509_cert_url: process.env.FIREBASE_AUTH_PROVIDER_X509_CERT_URL,
    client_x509_cert_url: process.env.FIREBASE_CLIENT_X509_CERT_URL,
    universe_domain: process.env.FIREBASE_UNIVERSE_DOMAIN,
    ANDROID_CLIENT_ID: process.env.ANDROID_CLIENT_ID,
    scheme: "myapp", // scheme bilgisini extra alana da ekleyin
  },
});