@@ -74,8 +74,7 @@ async function onAppleButtonPress() {
7474 const appleCredential = AppleAuthProvider .credential (identityToken, nonce);
7575
7676 // Sign the user in with the credential
77- const auth = getAuth ();
78- return signInWithCredential (auth, appleCredential);
77+ return signInWithCredential (getAuth (), appleCredential);
7978}
8079```
8180
@@ -85,7 +84,7 @@ with the new authentication state of the user.
8584Apple also requires that the app revoke the ` Sign in with Apple ` token when the user chooses to delete their account. This can be accomplished with the ` revokeToken ` API.
8685
8786``` js
88- import { getAuth } from ' @react-native-firebase/auth' ;
87+ import { getAuth , revokeToken } from ' @react-native-firebase/auth' ;
8988import { appleAuth } from ' @invertase/react-native-apple-authentication' ;
9089
9190async function revokeSignInWithAppleToken () {
@@ -100,8 +99,7 @@ async function revokeSignInWithAppleToken() {
10099 }
101100
102101 // Revoke the token
103- const auth = getAuth ();
104- return auth .revokeToken (auth, authorizationCode);
102+ return revokeToken (getAuth (), authorizationCode);
105103}
106104```
107105
@@ -158,8 +156,7 @@ async function onFacebookButtonPress() {
158156 const facebookCredential = FacebookAuthProvider .credential (data .accessToken );
159157
160158 // Sign-in the user with the credential
161- const auth = getAuth ();
162- return signInWithCredential (auth, facebookCredential);
159+ return signInWithCredential (getAuth (), facebookCredential);
163160}
164161```
165162
@@ -200,8 +197,7 @@ async function onFacebookButtonPress() {
200197 const facebookCredential = FacebookAuthProvider .credential (data .authenticationToken , nonce);
201198
202199 // Sign-in the user with the credential
203- const auth = getAuth ();
204- return signInWithCredential (auth, facebookCredential);
200+ return signInWithCredential (getAuth (), facebookCredential);
205201}
206202```
207203
@@ -277,8 +273,7 @@ async function onGoogleButtonPress() {
277273 const googleCredential = GoogleAuthProvider .credential (signInResult .data .idToken );
278274
279275 // Sign-in the user with the credential
280- const auth = getAuth ();
281- return signInWithCredential (auth, googleCredential);
276+ return signInWithCredential (getAuth (), googleCredential);
282277}
283278` ` `
284279
@@ -332,8 +327,7 @@ const onMicrosoftButtonPress = async () => {
332327 });
333328
334329 // Sign-in the user with the provider
335- const auth = getAuth ();
336- return signInWithRedirect (auth, provider);
330+ return signInWithRedirect (getAuth (), provider);
337331};
338332` ` `
339333
@@ -393,8 +387,7 @@ async function onTwitterButtonPress() {
393387 const twitterCredential = TwitterAuthProvider .credential (authToken, authTokenSecret);
394388
395389 // Sign-in the user with the credential
396- const auth = getAuth ();
397- return signInWithCredential (auth, twitterCredential);
390+ return signInWithCredential (getAuth (), twitterCredential);
398391}
399392` ` `
400393
@@ -417,8 +410,6 @@ This code demonstrates linking a Google provider to an account that is already s
417410import { GoogleAuthProvider , getAuth } from ' @react-native-firebase/auth' ;
418411import { GoogleSignin } from ' @react-native-google-signin/google-signin' ;
419412
420- const auth = getAuth ();
421-
422413async function onGoogleLinkButtonPress () {
423414 // Ensure the device supports Google Play services
424415 await GoogleSignin .hasPlayServices ({ showPlayServicesUpdateDialog: true });
@@ -429,7 +420,7 @@ async function onGoogleLinkButtonPress() {
429420 const googleCredential = GoogleAuthProvider .credential (idToken);
430421
431422 // Link the user's account with the Google credential
432- const firebaseUserCredential = await auth .currentUser .linkWithCredential (googleCredential);
423+ const firebaseUserCredential = await getAuth () .currentUser .linkWithCredential (googleCredential);
433424 // Handle the linked account as needed in your app
434425 return ;
435426}
0 commit comments