Skip to content

Commit 3099c74

Browse files
committed
add signInWithProvider with google, facebook
1 parent 9fd0865 commit 3099c74

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,31 @@ authManager.authorizeWithCallbackURL('twitter', appUrl)
250250
})
251251
```
252252

253+
### socialLogin with custom Library
254+
If you don't want to use [react-native-oauth](https://github.com/fullstackreact/react-native-oauth), you can use other library such as [react-native-facebook-login](https://github.com/magus/react-native-facebook-login).
255+
256+
```javascript
257+
var {FBLogin, FBLoginManager} = require('react-native-facebook-login');
258+
259+
var Login = React.createClass({
260+
render: function() {
261+
return (
262+
<FBLogin
263+
onLogin={function(data){
264+
console.log("Logged in!");
265+
console.log(data);
266+
let token = data.credentials.token
267+
firestack.signInWithProvider('facebook', token, '') // facebook need only access token.
268+
.then((user)=>{
269+
console.log(user)
270+
})
271+
}}
272+
/>
273+
);
274+
}
275+
});
276+
```
277+
253278
If the `signInWithProvider()` method resolves correct and we have already set up our `listenForAuth()` method properly, it will fire and we'll have a logged in user through Firebase.
254279

255280
### reauthenticateWithCredentialForProvider()

ios/Firestack/Firestack.m

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -619,6 +619,11 @@ - (FIRAuthCredential *)getCredentialForProvider:(NSString *)provider
619619
if ([provider isEqualToString: @"twitter"]) {
620620
credential = [FIRTwitterAuthProvider credentialWithToken:authToken
621621
secret:authTokenSecret];
622+
} if ([provider isEqualToString: @"facebook"]) {
623+
credential = [FIRFacebookAuthProvider credentialWithAccessToken:authToken];
624+
} if ([provider isEqualToString: @"google"]) {
625+
credential = [FIRGoogleAuthProvider credentialWithToken:authToken
626+
secret:authTokenSecret];
622627
} else {
623628
NSLog(@"Provider not yet handled");
624629
}

0 commit comments

Comments
 (0)