@@ -52,7 +52,7 @@ When the user presses the pre-rendered button, we can trigger the initial sign-i
52
52
passing in the scope required for our application:
53
53
54
54
``` js
55
- import auth from ' @react-native-firebase/auth' ;
55
+ import auth , { getAuth } from ' @react-native-firebase/auth' ;
56
56
import { appleAuth } from ' @invertase/react-native-apple-authentication' ;
57
57
58
58
async function onAppleButtonPress () {
@@ -74,7 +74,7 @@ async function onAppleButtonPress() {
74
74
const appleCredential = auth .AppleAuthProvider .credential (identityToken, nonce);
75
75
76
76
// Sign the user in with the credential
77
- return auth ().signInWithCredential (appleCredential);
77
+ return getAuth ().signInWithCredential (appleCredential);
78
78
}
79
79
```
80
80
@@ -84,7 +84,7 @@ with the new authentication state of the user.
84
84
Apple 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.
85
85
86
86
``` js
87
- import auth from ' @react-native-firebase/auth' ;
87
+ import { getAuth } from ' @react-native-firebase/auth' ;
88
88
import { appleAuth } from ' @invertase/react-native-apple-authentication' ;
89
89
90
90
async function revokeSignInWithAppleToken () {
@@ -99,7 +99,7 @@ async function revokeSignInWithAppleToken() {
99
99
}
100
100
101
101
// Revoke the token
102
- return auth ().revokeToken (authorizationCode);
102
+ return getAuth ().revokeToken (authorizationCode);
103
103
}
104
104
```
105
105
@@ -134,7 +134,7 @@ function FacebookSignIn() {
134
134
The ` onFacebookButtonPress ` can then be implemented as follows:
135
135
136
136
``` js
137
- import auth from ' @react-native-firebase/auth' ;
137
+ import auth , { getAuth } from ' @react-native-firebase/auth' ;
138
138
import { LoginManager , AccessToken } from ' react-native-fbsdk-next' ;
139
139
140
140
async function onFacebookButtonPress () {
@@ -156,7 +156,7 @@ async function onFacebookButtonPress() {
156
156
const facebookCredential = auth .FacebookAuthProvider .credential (data .accessToken );
157
157
158
158
// Sign-in the user with the credential
159
- return auth ().signInWithCredential (facebookCredential);
159
+ return getAuth ().signInWithCredential (facebookCredential);
160
160
}
161
161
```
162
162
@@ -165,7 +165,7 @@ async function onFacebookButtonPress() {
165
165
To use Facebook Limited Login instead of "classic" Facebook Login, the ` onFacebookButtonPress ` can then be implemented as follows:
166
166
167
167
``` js
168
- import auth from ' @react-native-firebase/auth' ;
168
+ import auth , { getAuth } from ' @react-native-firebase/auth' ;
169
169
import { LoginManager , AuthenticationToken } from ' react-native-fbsdk-next' ;
170
170
import { sha256 } from ' react-native-sha256' ;
171
171
@@ -197,7 +197,7 @@ async function onFacebookButtonPress() {
197
197
const facebookCredential = auth .FacebookAuthProvider .credential (data .authenticationToken , nonce);
198
198
199
199
// Sign-in the user with the credential
200
- return auth ().signInWithCredential (facebookCredential);
200
+ return getAuth ().signInWithCredential (facebookCredential);
201
201
}
202
202
```
203
203
@@ -243,7 +243,7 @@ function TwitterSignIn() {
243
243
The ` onTwitterButtonPress ` can then be implemented as follows:
244
244
245
245
``` js
246
- import auth from ' @react-native-firebase/auth' ;
246
+ import auth , { getAuth } from ' @react-native-firebase/auth' ;
247
247
import { NativeModules } from ' react-native' ;
248
248
const { RNTwitterSignIn } = NativeModules;
249
249
@@ -255,7 +255,7 @@ async function onTwitterButtonPress() {
255
255
const twitterCredential = auth .TwitterAuthProvider .credential (authToken, authTokenSecret);
256
256
257
257
// Sign-in the user with the credential
258
- return auth ().signInWithCredential (twitterCredential);
258
+ return getAuth ().signInWithCredential (twitterCredential);
259
259
}
260
260
```
261
261
@@ -305,7 +305,7 @@ function GoogleSignIn() {
305
305
The ` onGoogleButtonPress ` can then be implemented as follows:
306
306
307
307
``` js
308
- import auth from ' @react-native-firebase/auth' ;
308
+ import auth , { getAuth } from ' @react-native-firebase/auth' ;
309
309
import { GoogleSignin } from ' @react-native-google-signin/google-signin' ;
310
310
311
311
async function onGoogleButtonPress () {
@@ -328,7 +328,7 @@ async function onGoogleButtonPress() {
328
328
const googleCredential = auth .GoogleAuthProvider .credential (signInResult .data .idToken );
329
329
330
330
// Sign-in the user with the credential
331
- return auth ().signInWithCredential (googleCredential);
331
+ return getAuth ().signInWithCredential (googleCredential);
332
332
}
333
333
` ` `
334
334
@@ -365,7 +365,7 @@ function MicrosoftSignIn() {
365
365
` onMicrosoftButtonPress` can be implemented as the following:
366
366
367
367
` ` ` js
368
- import auth from ' @react-native-firebase/auth' ;
368
+ import auth , { getAuth } from ' @react-native-firebase/auth' ;
369
369
370
370
const onMicrosoftButtonPress = async () => {
371
371
// Generate the provider object
@@ -382,7 +382,7 @@ const onMicrosoftButtonPress = async () => {
382
382
});
383
383
384
384
// Sign-in the user with the provider
385
- return auth ().signInWithRedirect (provider);
385
+ return getAuth ().signInWithRedirect (provider);
386
386
};
387
387
` ` `
388
388
@@ -403,7 +403,7 @@ To achieve this, you should replace sign-in method in any of the supported socia
403
403
This code demonstrates linking a Google provider to an account that is already signed in using Firebase authentication.
404
404
405
405
` ` ` js
406
- import auth from ' @react-native-firebase/auth' ;
406
+ import auth , { getAuth } from ' @react-native-firebase/auth' ;
407
407
import { GoogleSignin } from ' @react-native-google-signin/google-signin' ;
408
408
409
409
async function onGoogleLinkButtonPress () {
@@ -416,7 +416,7 @@ async function onGoogleLinkButtonPress() {
416
416
const googleCredential = auth .GoogleAuthProvider .credential (idToken);
417
417
418
418
// 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);
420
420
// Handle the linked account as needed in your app
421
421
return ;
422
422
}
0 commit comments