Skip to content

Commit 3dfd285

Browse files
committed
Merge branch 'master' into anonymous
* master: Support asset-library / camera roll URLs Correctly send database_error event Remove firebase includes
2 parents d7f98e4 + 167d179 commit 3dfd285

10 files changed

+46
-15
lines changed

ios/Firestack/Firestack.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#import "Firestack.h"
88
#import "FirestackErrors.h"
99
#import "FirestackEvents.h"
10-
#import "FirestackAnalytics.h"
10+
// #import "FirestackAnalytics.h"
1111
// #import "FirestackCloudMessaging.h"
1212

1313
static Firestack *_sharedInstance = nil;

ios/Firestack/FirestackAnalytics.h

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

12-
#import "FirebaseAnalytics.h"
1312
#import "RCTBridgeModule.h"
1413

1514
@interface FirestackAnalytics : NSObject <RCTBridgeModule> {

ios/Firestack/FirestackAnalytics.m

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
#import "FirestackEvents.h"
1111
#import "FirestackAnalytics.h"
1212

13+
@import FirebaseAnalytics;
14+
1315
@implementation FirestackAnalytics
1416

1517
- (void)dealloc

ios/Firestack/FirestackCloudMessaging.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
#define FirestackCloudMessaging_h
1111

1212
#import "Firebase.h"
13-
#import "FirebaseMessaging.h"
1413
#import "RCTEventEmitter.h"
1514
#import "RCTBridgeModule.h"
1615
#import "RCTUtils.h"

ios/Firestack/FirestackCloudMessaging.m

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
#import "FirestackCloudMessaging.h"
1515
#import "FirestackEvents.h"
1616
#import "RCTConvert.h"
17-
#import "FirestackCloudMessaging.h"
1817

1918
// https://github.com/facebook/react-native/blob/master/Libraries/PushNotificationIOS/RCTPushNotificationManager.m
2019
@implementation RCTConvert (UILocalNotification)

ios/Firestack/FirestackDatabase.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
#define FirestackDatabase_h
1111

1212
#import "Firebase.h"
13-
#import "FirebaseDatabase.h"
1413
#import "RCTEventEmitter.h"
1514
#import "RCTBridgeModule.h"
1615

ios/Firestack/FirestackDatabase.m

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,8 @@ @implementation FirestackDatabase
358358
NSDictionary *props =
359359
[self snapshotToDict:snapshot];
360360
[self
361-
sendJSEvent:eventName
361+
sendJSEvent:DATABASE_DATA_EVENT
362+
title:eventName
362363
props: @{
363364
@"eventName": eventName,
364365
@"path": path,
@@ -676,6 +677,7 @@ - (NSDictionary *) getAndSendDatabaseError:(NSError *) error
676677
};
677678
[self
678679
sendJSEvent:DATABASE_ERROR_EVENT
680+
title:DATABASE_ERROR_EVENT
679681
props: evt];
680682

681683
return evt;
@@ -686,11 +688,12 @@ - (NSDictionary *) getAndSendDatabaseError:(NSError *) error
686688
return @[DATABASE_DATA_EVENT, DATABASE_ERROR_EVENT];
687689
}
688690

689-
- (void) sendJSEvent:(NSString *)title
691+
- (void) sendJSEvent:(NSString *)type
692+
title:(NSString *)title
690693
props:(NSDictionary *)props
691694
{
692695
@try {
693-
[self sendEventWithName:DATABASE_DATA_EVENT
696+
[self sendEventWithName:type
694697
body:@{
695698
@"eventName": title,
696699
@"body": props

ios/Firestack/FirestackErrors.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
#import "RCTBridgeModule.h"
1313
#import "Firebase.h"
14-
#import "FirebaseAuth.h"
1514

1615
@interface FirestackErrors : NSObject <RCTBridgeModule> {
1716

ios/Firestack/FirestackStorage.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
#define FirestackStorage_h
1111

1212
#import "Firebase.h"
13-
#import "FirebaseStorage.h"
1413
#import "RCTBridgeModule.h"
1514
#import "RCTEventEmitter.h"
1615

ios/Firestack/FirestackStorage.m

Lines changed: 37 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
#import "FirestackStorage.h"
1010
#import "FirestackEvents.h"
1111

12+
#import <Photos/Photos.h>
13+
1214
@implementation FirestackStorage
1315

1416
RCT_EXPORT_MODULE(FirestackStorage);
@@ -51,15 +53,45 @@ @implementation FirestackStorage
5153
return callback(@[err]);
5254
}
5355

56+
if ([path hasPrefix:@"assets-library://"]) {
57+
NSURL *localFile = [[NSURL alloc] initWithString:path];
58+
PHFetchResult* assets = [PHAsset fetchAssetsWithALAssetURLs:@[localFile] options:nil];
59+
PHAsset *asset = [assets firstObject];
60+
[asset requestContentEditingInputWithOptions:nil
61+
completionHandler:^(PHContentEditingInput *contentEditingInput, NSDictionary *info) {
62+
NSURL *imageFile = contentEditingInput.fullSizeImageURL;
63+
64+
[self performUpload:urlStr
65+
name:name
66+
file:imageFile
67+
metadata:nil
68+
callback:callback];
69+
}];
70+
} else {
71+
NSURL *localFile = [NSURL fileURLWithPath:path];
72+
FIRStorageMetadata *firmetadata = [[FIRStorageMetadata alloc] initWithDictionary:metadata];
73+
74+
[self performUpload:urlStr
75+
name:name
76+
file:localFile
77+
metadata:firmetadata
78+
callback:callback];
79+
}
80+
81+
}
82+
83+
- (void) performUpload:(NSString *) urlStr
84+
name:(NSString *) name
85+
file:(NSURL *) imageFile
86+
metadata:(FIRStorageMetadata *) firmetadata
87+
callback:(RCTResponseSenderBlock) callback
88+
{
5489
FIRStorageReference *storageRef = [[FIRStorage storage] referenceForURL:urlStr];
5590
FIRStorageReference *uploadRef = [storageRef child:name];
5691

57-
NSURL *localFile = [NSURL fileURLWithPath:path];
58-
59-
FIRStorageMetadata *firmetadata = [[FIRStorageMetadata alloc] initWithDictionary:metadata];
60-
61-
FIRStorageUploadTask *uploadTask = [uploadRef putFile:localFile
92+
FIRStorageUploadTask *uploadTask = [uploadRef putFile:imageFile
6293
metadata:firmetadata];
94+
6395
// Listen for state changes, errors, and completion of the upload.
6496
[uploadTask observeStatus:FIRStorageTaskStatusResume handler:^(FIRStorageTaskSnapshot *snapshot) {
6597
// Upload resumed, also fires when the upload starts

0 commit comments

Comments
 (0)