Skip to content

Commit f72b696

Browse files
committed
signin with email, added once
1 parent 3b0df30 commit f72b696

File tree

5 files changed

+53
-13
lines changed

5 files changed

+53
-13
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -557,4 +557,5 @@ The following is left to be done:
557557
- [x] Add Cloud Messaging
558558
- [ ] Add JS api
559559
- [ ] Move to use swift (cleaner syntax)
560+
- [ ] Finish module breaking
560561
- [ ] TODO: Finish Facebook integration

ios/Firestack/Firestack.m

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ @implementation Firestack
3232
} else {
3333
bundleID = [[NSBundle mainBundle] bundleIdentifier];
3434
}
35+
3536
// Prefer the user configuration options over the default options
3637
NSArray *keyOptions = @[@"APIKey", @"clientID", @"trackingID",
3738
@"GCMSenderID", @"androidClientID",
@@ -56,6 +57,11 @@ @implementation Firestack
5657
}
5758
}
5859

60+
// If the apiKey is lowercase
61+
if ([opts valueForKey:@"apiKey"]) {
62+
[props setValue:[opts valueForKey:@"apiKey"] forKey:@"APIKey"];
63+
}
64+
5965
@try {
6066
FIROptions *finalOptions = [[FIROptions alloc] initWithGoogleAppID:[props valueForKey:@"googleAppID"]
6167
bundleID:bundleID

ios/Firestack/FirestackDatabase.m

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,6 @@ @implementation FirestackDatabase
8787
withBlock:^(FIRDataSnapshot * _Nonnull snapshot) {
8888
NSDictionary *props =
8989
[self snapshotToDict:snapshot];
90-
91-
NSLog(@"props: %@", props);
9290
[self
9391
sendJSEvent:name
9492
props: @{
@@ -260,7 +258,8 @@ - (NSDictionary *) getAndSendDatabaseError:(NSError *) error
260258
DATABASE_CHILD_ADDED_EVENT,
261259
DATABASE_CHILD_MODIFIED_EVENT,
262260
DATABASE_CHILD_MOVED_EVENT,
263-
DATABASE_CHILD_REMOVED_EVENT
261+
DATABASE_CHILD_REMOVED_EVENT,
262+
DATABASE_ERROR_EVENT
264263
];
265264
}
266265

ios/FirestackAuth.m

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,9 @@ @implementation FirestackAuth
9898

9999
RCT_EXPORT_METHOD(listenForAuth)
100100
{
101-
self->authListenerHandle = [[FIRAuth auth] addAuthStateDidChangeListener:^(FIRAuth *_Nonnull auth,
102-
FIRUser *_Nullable user) {
101+
self->authListenerHandle =
102+
[[FIRAuth auth] addAuthStateDidChangeListener:^(FIRAuth *_Nonnull auth,
103+
FIRUser *_Nullable user) {
103104

104105
if (user != nil) {
105106
// User is signed in.
@@ -457,8 +458,13 @@ - (FIRAuthCredential *)getCredentialForProvider:(NSString *)provider
457458
- (void) sendJSEvent:(NSString *)title
458459
props:(NSDictionary *)props
459460
{
460-
[self sendEventWithName:title
461-
body:props];
461+
@try {
462+
[self sendEventWithName:title
463+
body:props];
464+
}
465+
@catch (NSException *err) {
466+
NSLog(@"An error occurred in sendJSEvent: %@", [err debugDescription]);
467+
}
462468
}
463469

464470

lib/modules/database.js

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,40 @@ class DatabaseRef {
4242
this.remove = this.removeAt;
4343
}
4444

45-
setAt(value) {
46-
return promisify('set', FirestackDatabase)(this.path, value)
45+
getAt(key) {
46+
let path = this.path;
47+
if (key && typeof(key) == 'string') {
48+
path = `${path}/${key}`
49+
}
50+
return promisify('onOnce', FirestackDatabase)(path);
51+
}
52+
53+
setAt(key, value) {
54+
let path = this.path;
55+
if (key && typeof(key) == 'string' && value) {
56+
path = `${path}/${key}`
57+
} else {
58+
value = key;
59+
}
60+
return promisify('set', FirestackDatabase)(path, value)
4761
}
4862

49-
updateAt(value) {
50-
return promisify('update', FirestackDatabase)(this.path, value)
63+
updateAt(key, value) {
64+
let path = this.path;
65+
if (key && typeof(key) == 'string' && value) {
66+
path = `${path}/${key}`
67+
} else {
68+
value = key;
69+
}
70+
return promisify('update', FirestackDatabase)(path, value)
5171
}
5272

53-
removeAt() {
54-
return promisify('remove', FirestackDatabase)(this.path)
73+
removeAt(key) {
74+
let path = this.path;
75+
if (key && typeof(key) == 'string') {
76+
path = `${path}/${key}`
77+
}
78+
return promisify('remove', FirestackDatabase)(path)
5579
}
5680

5781
on(evt, cb) {
@@ -70,6 +94,10 @@ class DatabaseRef {
7094
});
7195
}
7296

97+
once(evt, cb) {
98+
return promisify('onOnce', FirestackDatabase)(this.path, evt);
99+
}
100+
73101
off(evt) {
74102
let promises = [];
75103
this.handles.forEach(handle => {

0 commit comments

Comments
 (0)