@@ -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
@@ -235,6 +235,7 @@ GoogleSignin.configure({
235
235
Once initialized, setup your application to trigger a sign-in request with Google using the ` signIn ` method.
236
236
237
237
``` jsx
238
+ import React from ' react' ;
238
239
import { Button } from ' react-native' ;
239
240
240
241
function GoogleSignIn () {
@@ -250,7 +251,7 @@ function GoogleSignIn() {
250
251
The ` onGoogleButtonPress ` can then be implemented as follows:
251
252
252
253
``` js
253
- import auth from ' @react-native-firebase/auth' ;
254
+ import auth , { getAuth } from ' @react-native-firebase/auth' ;
254
255
import { GoogleSignin } from ' @react-native-google-signin/google-signin' ;
255
256
256
257
async function onGoogleButtonPress () {
@@ -273,7 +274,7 @@ async function onGoogleButtonPress() {
273
274
const googleCredential = auth .GoogleAuthProvider .credential (signInResult .data .idToken );
274
275
275
276
// Sign-in the user with the credential
276
- return auth ().signInWithCredential (googleCredential);
277
+ return getAuth ().signInWithCredential (googleCredential);
277
278
}
278
279
` ` `
279
280
@@ -310,7 +311,7 @@ function MicrosoftSignIn() {
310
311
` onMicrosoftButtonPress` can be implemented as the following:
311
312
312
313
` ` ` js
313
- import auth from ' @react-native-firebase/auth' ;
314
+ import auth , { getAuth } from ' @react-native-firebase/auth' ;
314
315
315
316
const onMicrosoftButtonPress = async () => {
316
317
// Generate the provider object
@@ -327,7 +328,7 @@ const onMicrosoftButtonPress = async () => {
327
328
});
328
329
329
330
// Sign-in the user with the provider
330
- return auth ().signInWithRedirect (provider);
331
+ return getAuth ().signInWithRedirect (provider);
331
332
};
332
333
` ` `
333
334
@@ -406,7 +407,7 @@ To achieve this, you should replace sign-in method in any of the supported socia
406
407
This code demonstrates linking a Google provider to an account that is already signed in using Firebase authentication.
407
408
408
409
` ` ` js
409
- import auth from ' @react-native-firebase/auth' ;
410
+ import auth , { getAuth } from ' @react-native-firebase/auth' ;
410
411
import { GoogleSignin } from ' @react-native-google-signin/google-signin' ;
411
412
412
413
async function onGoogleLinkButtonPress () {
@@ -419,7 +420,7 @@ async function onGoogleLinkButtonPress() {
419
420
const googleCredential = auth .GoogleAuthProvider .credential (idToken);
420
421
421
422
// Link the user's account with the Google credential
422
- const firebaseUserCredential = await auth ().currentUser .linkWithCredential (googleCredential);
423
+ const firebaseUserCredential = await getAuth ().currentUser .linkWithCredential (googleCredential);
423
424
// Handle the linked account as needed in your app
424
425
return ;
425
426
}
0 commit comments