Skip to content

Commit eae4423

Browse files
committed
added support for signInWithCustomToken on ios
1 parent 155b219 commit eae4423

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

firestack.ios.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,15 @@ export default class Firestack {
8080
return promisify('signInWithProvider')(provider, authToken, authSecret);
8181
}
8282

83+
/**
84+
* Sign the user in with a custom auth token
85+
* @param {string} customToken A self-signed custom auth token.
86+
* @return {Promise} A promise resolved upon completion
87+
*/
88+
signInWithCustomToken(customToken) {
89+
return promisify('signInWithCustomToken')(customToken);
90+
}
91+
8392
/**
8493
* Reauthenticate a user with a third-party authentication provider
8594
* @param {string} provider The provider name

ios/Firestack/Firestack.m

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,27 @@ @implementation Firestack
2828
}
2929
}
3030

31+
RCT_EXPORT_METHOD(signInWithCustomToken:
32+
(NSString *)customToken
33+
callback:(RCTResponseSenderBlock) callback)
34+
{
35+
[[FIRAuth auth]
36+
signInWithCustomToken:customToken
37+
completion:^(FIRUser *user, NSError *error) {
38+
39+
if (user != nil) {
40+
NSDictionary *userProps = [self userPropsFromFIRUser:user];
41+
callback(@[[NSNull null], userProps]);
42+
} else {
43+
NSDictionary *err =
44+
[self handleFirebaseError:@"signinError"
45+
error:error
46+
withUser:user];
47+
callback(@[err]);
48+
}
49+
}];
50+
}
51+
3152
RCT_EXPORT_METHOD(signInWithProvider:
3253
(NSString *)provider
3354
token:(NSString *)authToken

0 commit comments

Comments
 (0)