Skip to content

Commit 8fc12c1

Browse files
authored
Merge branch 'v3' into master
2 parents 4994768 + 7de26d3 commit 8fc12c1

24 files changed

+417
-90
lines changed

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,24 @@ We have a working application example available in at [fullstackreact/FirestackA
4444
* [Events](docs/api/events.md)
4545
* [Redux](docs/redux.md)
4646

47+
## Feature overview
48+
Feature | Firestack | Firebase
49+
------------ | ------------- | -------------
50+
Real time database | -- | YES
51+
Authentication | -- | YES
52+
Cloud messaging | -- | YES
53+
Storage | -- | YES
54+
Crash reporting | -- | YES
55+
Notifications | -- | YES
56+
Remote config | -- | YES
57+
Dynamic links | -- | YES
58+
AdMob | -- | YES
59+
Analytics | -- | YES
60+
App indexing | -- | YES
61+
Hosting | -- | YES
62+
AdWords | -- | YES
63+
Invites | -- | YES
64+
4765
## Contributing
4866

4967
For a detailed discussion of how Firestack works as well as how to contribute, check out our [contribution guide](https://github.com/fullstackreact/react-native-firestack/blob/master/Contributing.md).

android/.idea/gradle.xml

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

android/build.gradle

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,13 @@ allprojects {
4444

4545
dependencies {
4646
compile 'com.facebook.react:react-native:0.20.+'
47-
compile 'com.google.android.gms:play-services-base:9.8.0'
48-
compile 'com.google.firebase:firebase-core:9.8.0'
49-
compile 'com.google.firebase:firebase-config:9.8.0'
50-
compile 'com.google.firebase:firebase-auth:9.8.0'
51-
compile 'com.google.firebase:firebase-analytics:9.8.0'
52-
compile 'com.google.firebase:firebase-database:9.8.0'
53-
compile 'com.google.firebase:firebase-storage:9.8.0'
54-
compile 'com.google.firebase:firebase-messaging:9.8.0'
47+
compile 'com.google.android.gms:play-services-base:+'
48+
compile 'com.google.firebase:firebase-core:10.0.1'
49+
compile 'com.google.firebase:firebase-config:10.0.1'
50+
compile 'com.google.firebase:firebase-auth:10.0.1'
51+
compile 'com.google.firebase:firebase-analytics:10.0.1'
52+
compile 'com.google.firebase:firebase-database:10.0.1'
53+
compile 'com.google.firebase:firebase-storage:10.0.1'
54+
compile 'com.google.firebase:firebase-messaging:10.0.1'
5555
}
5656

docs/api/authentication.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ Sign in the user with a 3rd party credential provider. `credential` requires the
100100

101101
```javascript
102102
const credential = {
103-
provider: 'facebook.com',
103+
provider: 'facebook',
104104
token: '12345',
105105
secret: '6789',
106106
};

docs/api/database.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,34 @@ firestack.database()
2525
});
2626
```
2727

28+
Test value exists at location:
29+
```javascript
30+
firestack.database()
31+
.ref('posts/1234')
32+
.on('value', (snapshot) => {
33+
const exists = snapshot.exists();
34+
});
35+
```
36+
37+
Basic write with priority example:
38+
```javascript
39+
firestack.database()
40+
.ref('posts/1235')
41+
.setWithPriority({
42+
title: 'Another Awesome Post',
43+
content: 'Some awesome content',
44+
}, 10);
45+
```
46+
Useful for `orderByPriority` queries.
47+
48+
49+
Transaction Support:
50+
```javascript
51+
firestack.database()
52+
.ref('posts/1234/title')
53+
.transaction((title) => 'My Awesome Post');
54+
```
55+
2856
## Unmounted components
2957

3058
Listening to database updates on unmounted components will trigger a warning:

ios/Firestack/Firestack.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
#define Firestack_h
99

1010
#import <UIKit/UIKit.h>
11-
#import "RCTBridgeModule.h"
12-
#import "RCTEventDispatcher.h"
13-
#import "RCTEventEmitter.h"
11+
#import <React/RCTBridgeModule.h>
12+
#import <React/RCTEventDispatcher.h>
13+
#import <React/RCTEventEmitter.h>
1414

1515
@interface Firestack : RCTEventEmitter <RCTBridgeModule> {
1616
}

ios/Firestack/Firestack.m

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,12 @@ + (void) initializeFirestack:(Firestack *) instance
5353
dispatch_once(&onceToken, ^{
5454
_sharedInstance = instance;
5555

56+
/* RCTReloadNotification is deprecated
5657
[[NSNotificationCenter defaultCenter] addObserver:self
5758
selector:@selector(reloadFirestack)
5859
name:RCTReloadNotification
5960
object:nil];
61+
*/
6062

6163
[[NSNotificationCenter defaultCenter]
6264
postNotificationName:kFirestackInitialized

ios/Firestack/FirestackAnalytics.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#ifndef FirestackAnalytics_h
1010
#define FirestackAnalytics_h
1111

12-
#import "RCTBridgeModule.h"
12+
#import <React/RCTBridgeModule.h>
1313

1414
@interface FirestackAnalytics : NSObject <RCTBridgeModule> {
1515

ios/Firestack/FirestackAuth.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
#define FirestackAuth_h
1111

1212
#import "Firebase.h"
13-
#import "RCTEventEmitter.h"
14-
#import "RCTBridgeModule.h"
13+
#import <React/RCTEventEmitter.h>
14+
#import <React/RCTBridgeModule.h>
1515

1616
@interface FirestackAuth : RCTEventEmitter <RCTBridgeModule> {
1717
FIRAuthStateDidChangeListenerHandle authListenerHandle;

ios/Firestack/FirestackAuth.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ @implementation FirestackAuth
314314
if (error) {
315315
[self userErrorCallback:callback error:error user:user msg:@"getTokenError"];
316316
} else {
317-
[self userCallback:callback user:user];
317+
callback(@[[NSNull null], token]);
318318
}
319319
}];
320320
} else {
@@ -331,7 +331,7 @@ @implementation FirestackAuth
331331
if (error) {
332332
[self userErrorCallback:callback error:error user:user msg:@"getTokenWithCompletion"];
333333
} else {
334-
[self userCallback:callback user:user];
334+
callback(@[[NSNull null], token]);
335335
}
336336
}];
337337
} else {

ios/Firestack/FirestackCloudMessaging.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
#define FirestackCloudMessaging_h
1111

1212
#import "Firebase.h"
13-
#import "RCTEventEmitter.h"
14-
#import "RCTBridgeModule.h"
15-
#import "RCTUtils.h"
13+
#import <React/RCTEventEmitter.h>
14+
#import <React/RCTBridgeModule.h>
15+
#import <React/RCTUtils.h>
1616

1717
@interface FirestackCloudMessaging : RCTEventEmitter <RCTBridgeModule> {
1818

ios/Firestack/FirestackCloudMessaging.m

Lines changed: 31 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -13,28 +13,7 @@
1313
#endif
1414
#import "FirestackCloudMessaging.h"
1515
#import "FirestackEvents.h"
16-
#import "RCTConvert.h"
17-
18-
// https://github.com/facebook/react-native/blob/master/Libraries/PushNotificationIOS/RCTPushNotificationManager.m
19-
@implementation RCTConvert (UILocalNotification)
20-
21-
+ (UILocalNotification *)UILocalNotification:(id)json
22-
{
23-
NSDictionary<NSString *, id> *details = [self NSDictionary:json];
24-
UILocalNotification *notification = [UILocalNotification new];
25-
notification.fireDate = [RCTConvert NSDate:details[@"fireDate"]] ?: [NSDate date];
26-
notification.alertBody = [RCTConvert NSString:details[@"alertBody"]];
27-
notification.alertAction = [RCTConvert NSString:details[@"alertAction"]];
28-
notification.soundName = [RCTConvert NSString:details[@"soundName"]] ?: UILocalNotificationDefaultSoundName;
29-
notification.userInfo = [RCTConvert NSDictionary:details[@"userInfo"]];
30-
notification.category = [RCTConvert NSString:details[@"category"]];
31-
if (details[@"applicationIconBadgeNumber"]) {
32-
notification.applicationIconBadgeNumber = [RCTConvert NSInteger:details[@"applicationIconBadgeNumber"]];
33-
}
34-
return notification;
35-
}
36-
37-
@end
16+
// #import "RCTConvert.h"
3817

3918
@implementation FirestackCloudMessaging
4019

@@ -89,34 +68,39 @@ + (void) setup:(UIApplication *) application
8968
selector:@selector(handleTokenRefresh)
9069
name:kFIRInstanceIDTokenRefreshNotification
9170
object: nil];
71+
}
9272

73+
#pragma mark Request permissions
74+
- (void) requestPermissions:(NSDictionary *)requestedPermissions
75+
callback:(RCTResponseSenderBlock) callback
76+
{
9377
if (SYSTEM_VERSION_LESS_THAN_OR_EQUAL_TO(@"9.0")) {
94-
UIUserNotificationType allNotificationTypes =
95-
(UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge);
96-
UIUserNotificationSettings *settings =
97-
[UIUserNotificationSettings settingsForTypes:allNotificationTypes categories:nil];
98-
[[UIApplication sharedApplication] registerUserNotificationSettings:settings];
99-
} else {
100-
// iOS 10 or later
101-
#if defined(__IPHONE_10_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0
102-
UNAuthorizationOptions authOptions =
103-
UNAuthorizationOptionAlert
104-
| UNAuthorizationOptionSound
105-
| UNAuthorizationOptionBadge;
106-
[[UNUserNotificationCenter currentNotificationCenter]
107-
requestAuthorizationWithOptions:authOptions
108-
completionHandler:^(BOOL granted, NSError * _Nullable error) {
109-
}
110-
];
111-
112-
// For iOS 10 display notification (sent via APNS)
113-
[[UNUserNotificationCenter currentNotificationCenter] setDelegate:self];
114-
// For iOS 10 data message (sent via FCM)
115-
[[FIRMessaging messaging] setRemoteMessageDelegate:self];
116-
#endif
117-
}
78+
UIUserNotificationType allNotificationTypes =
79+
(UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge);
80+
UIUserNotificationSettings *settings =
81+
[UIUserNotificationSettings settingsForTypes:allNotificationTypes categories:nil];
82+
[[UIApplication sharedApplication] registerUserNotificationSettings:settings];
83+
} else {
84+
// iOS 10 or later
85+
#if defined(__IPHONE_10_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0
86+
UNAuthorizationOptions authOptions =
87+
UNAuthorizationOptionAlert
88+
| UNAuthorizationOptionSound
89+
| UNAuthorizationOptionBadge;
90+
[[UNUserNotificationCenter currentNotificationCenter]
91+
requestAuthorizationWithOptions:authOptions
92+
completionHandler:^(BOOL granted, NSError * _Nullable error) {
93+
}
94+
];
95+
96+
// For iOS 10 display notification (sent via APNS)
97+
[[UNUserNotificationCenter currentNotificationCenter] setDelegate:self];
98+
// For iOS 10 data message (sent via FCM)
99+
[[FIRMessaging messaging] setRemoteMessageDelegate:self];
100+
#endif
101+
}
118102

119-
[[UIApplication sharedApplication] registerForRemoteNotifications];
103+
[[UIApplication sharedApplication] registerForRemoteNotifications];
120104
}
121105

122106
#pragma mark callbacks

ios/Firestack/FirestackDatabase.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,16 @@
1010
#define FirestackDatabase_h
1111

1212
#import "Firebase.h"
13-
#import "RCTEventEmitter.h"
14-
#import "RCTBridgeModule.h"
13+
#import <React/RCTEventEmitter.h>
14+
#import <React/RCTBridgeModule.h>
1515

1616
@interface FirestackDatabase : RCTEventEmitter <RCTBridgeModule> {
1717

1818
}
1919

2020
@property NSMutableDictionary *dbReferences;
21+
@property NSMutableDictionary *transactions;
22+
@property dispatch_queue_t transactionQueue;
2123

2224
@end
2325

0 commit comments

Comments
 (0)