[ios][storage] now detects if pod installed (makes the pod an optional dependency)

This commit is contained in:
Salakar 2017-05-25 15:14:01 +01:00
parent 410f260fc0
commit 531acece76
2 changed files with 34 additions and 28 deletions

View File

@ -1,7 +1,6 @@
#ifndef RNFirebaseStorage_h
#define RNFirebaseStorage_h
#import "Firebase.h"
#if __has_include(<React/RCTEventEmitter.h>)
#import <React/RCTEventEmitter.h>
#else // Compatibility for RN version < 0.40
@ -17,8 +16,6 @@
}
@property (nonatomic) NSString *_storageUrl;
@end
#endif

View File

@ -1,7 +1,9 @@
#import "RNFirebaseStorage.h"
#import "RNFirebaseEvents.h"
#if __has_include(<FirebaseStorage/FIRStorage.h>)
#import "RNFirebaseEvents.h"
#import <Photos/Photos.h>
#import "Firebase.h"
@implementation RNFirebaseStorage
@ -23,7 +25,7 @@ RCT_EXPORT_MODULE(RNFirebaseStorage);
NSString *message = [error localizedDescription];
NSDictionary *userInfo = [error userInfo];
NSError *underlyingError = [userInfo objectForKey:NSUnderlyingErrorKey];
NSError *underlyingError = userInfo[NSUnderlyingErrorKey];
NSString *underlyingErrorDescription = [underlyingError localizedDescription];
switch (error.code) {
@ -80,7 +82,7 @@ RCT_EXPORT_MODULE(RNFirebaseStorage);
break;
}
if (userInfo != nil && [userInfo objectForKey:@"data"]) {
if (userInfo != nil && userInfo[@"data"]) {
// errors with 'data' are unserializable - it breaks react so we send nil instead
reject(code, message, nil);
} else {
@ -267,7 +269,7 @@ RCT_EXPORT_METHOD(putFile:(NSString *) path localPath:(NSString *)localPath meta
PHImageRequestOptions *options = [PHImageRequestOptions new];
options.networkAccessAllowed = true;
[[PHImageManager defaultManager] requestImageDataForAsset:asset options:options resultHandler:^(NSData * imageData, NSString * dataUTI, UIImageOrientation orientation, NSDictionary * info) {
if ([info objectForKey:PHImageErrorKey] == nil) {
if (info[PHImageErrorKey] == nil) {
[self uploadData:imageData metadata:metadata path:path resolver:resolve rejecter:reject];
} else {
reject(@"storage/request-image-data-failed", @"Could not obtain image data for the specified file.", nil);
@ -445,3 +447,10 @@ RCT_EXPORT_METHOD(putFile:(NSString *) path localPath:(NSString *)localPath meta
@end
#else
@implementation RNFirebaseStorage
RCT_EXPORT_MODULE();
RCT_EXPORT_METHOD(nativeSDKMissing) {}
@end
#endif