@@ -52,7 +52,7 @@ When the user presses the pre-rendered button, we can trigger the initial sign-i
5252passing in the scope required for our application:
5353
5454``` js
55- import auth from ' @react-native-firebase/auth' ;
55+ import auth , { getAuth } from ' @react-native-firebase/auth' ;
5656import { appleAuth } from ' @invertase/react-native-apple-authentication' ;
5757
5858async function onAppleButtonPress () {
@@ -74,7 +74,7 @@ async function onAppleButtonPress() {
7474 const appleCredential = auth .AppleAuthProvider .credential (identityToken, nonce);
7575
7676 // Sign the user in with the credential
77- return auth ().signInWithCredential (appleCredential);
77+ return getAuth ().signInWithCredential (appleCredential);
7878}
7979```
8080
@@ -84,7 +84,7 @@ with the new authentication state of the user.
8484Apple 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.
8585
8686``` js
87- import auth from ' @react-native-firebase/auth' ;
87+ import { getAuth } from ' @react-native-firebase/auth' ;
8888import { appleAuth } from ' @invertase/react-native-apple-authentication' ;
8989
9090async function revokeSignInWithAppleToken () {
@@ -99,7 +99,7 @@ async function revokeSignInWithAppleToken() {
9999 }
100100
101101 // Revoke the token
102- return auth ().revokeToken (authorizationCode);
102+ return getAuth ().revokeToken (authorizationCode);
103103}
104104```
105105
@@ -134,7 +134,7 @@ function FacebookSignIn() {
134134The ` onFacebookButtonPress ` can then be implemented as follows:
135135
136136``` js
137- import auth from ' @react-native-firebase/auth' ;
137+ import auth , { getAuth } from ' @react-native-firebase/auth' ;
138138import { LoginManager , AccessToken } from ' react-native-fbsdk-next' ;
139139
140140async function onFacebookButtonPress () {
@@ -156,7 +156,7 @@ async function onFacebookButtonPress() {
156156 const facebookCredential = auth .FacebookAuthProvider .credential (data .accessToken );
157157
158158 // Sign-in the user with the credential
159- return auth ().signInWithCredential (facebookCredential);
159+ return getAuth ().signInWithCredential (facebookCredential);
160160}
161161```
162162
@@ -165,7 +165,7 @@ async function onFacebookButtonPress() {
165165To use Facebook Limited Login instead of "classic" Facebook Login, the ` onFacebookButtonPress ` can then be implemented as follows:
166166
167167``` js
168- import auth from ' @react-native-firebase/auth' ;
168+ import auth , { getAuth } from ' @react-native-firebase/auth' ;
169169import { LoginManager , AuthenticationToken } from ' react-native-fbsdk-next' ;
170170import { sha256 } from ' react-native-sha256' ;
171171
@@ -197,7 +197,7 @@ async function onFacebookButtonPress() {
197197 const facebookCredential = auth .FacebookAuthProvider .credential (data .authenticationToken , nonce);
198198
199199 // Sign-in the user with the credential
200- return auth ().signInWithCredential (facebookCredential);
200+ return getAuth ().signInWithCredential (facebookCredential);
201201}
202202```
203203
@@ -243,7 +243,7 @@ function TwitterSignIn() {
243243The ` onTwitterButtonPress ` can then be implemented as follows:
244244
245245``` js
246- import auth from ' @react-native-firebase/auth' ;
246+ import auth , { getAuth } from ' @react-native-firebase/auth' ;
247247import { NativeModules } from ' react-native' ;
248248const { RNTwitterSignIn } = NativeModules;
249249
@@ -255,7 +255,7 @@ async function onTwitterButtonPress() {
255255 const twitterCredential = auth .TwitterAuthProvider .credential (authToken, authTokenSecret);
256256
257257 // Sign-in the user with the credential
258- return auth ().signInWithCredential (twitterCredential);
258+ return getAuth ().signInWithCredential (twitterCredential);
259259}
260260```
261261
@@ -305,7 +305,7 @@ function GoogleSignIn() {
305305The ` onGoogleButtonPress ` can then be implemented as follows:
306306
307307``` js
308- import auth from ' @react-native-firebase/auth' ;
308+ import auth , { getAuth } from ' @react-native-firebase/auth' ;
309309import { GoogleSignin } from ' @react-native-google-signin/google-signin' ;
310310
311311async function onGoogleButtonPress () {
@@ -328,7 +328,7 @@ async function onGoogleButtonPress() {
328328 const googleCredential = auth .GoogleAuthProvider .credential (signInResult .data .idToken );
329329
330330 // Sign-in the user with the credential
331- return auth ().signInWithCredential (googleCredential);
331+ return getAuth ().signInWithCredential (googleCredential);
332332}
333333` ` `
334334
@@ -365,7 +365,7 @@ function MicrosoftSignIn() {
365365` onMicrosoftButtonPress` can be implemented as the following:
366366
367367` ` ` js
368- import auth from ' @react-native-firebase/auth' ;
368+ import auth , { getAuth } from ' @react-native-firebase/auth' ;
369369
370370const onMicrosoftButtonPress = async () => {
371371 // Generate the provider object
@@ -382,7 +382,7 @@ const onMicrosoftButtonPress = async () => {
382382 });
383383
384384 // Sign-in the user with the provider
385- return auth ().signInWithRedirect (provider);
385+ return getAuth ().signInWithRedirect (provider);
386386};
387387` ` `
388388
@@ -403,7 +403,7 @@ To achieve this, you should replace sign-in method in any of the supported socia
403403This code demonstrates linking a Google provider to an account that is already signed in using Firebase authentication.
404404
405405` ` ` js
406- import auth from ' @react-native-firebase/auth' ;
406+ import auth , { getAuth } from ' @react-native-firebase/auth' ;
407407import { GoogleSignin } from ' @react-native-google-signin/google-signin' ;
408408
409409async function onGoogleLinkButtonPress () {
@@ -416,7 +416,7 @@ async function onGoogleLinkButtonPress() {
416416 const googleCredential = auth .GoogleAuthProvider .credential (idToken);
417417
418418 // Link the user's account with the Google credential
419- const firebaseUserCredential = await auth ().currentUser .linkWithCredential (googleCredential);
419+ const firebaseUserCredential = await getAuth ().currentUser .linkWithCredential (googleCredential);
420420 // Handle the linked account as needed in your app
421421 return ;
422422}
0 commit comments