add local identifier to the image dictionary result after capture a photo
This commit is contained in:
parent
8246d99d98
commit
2c56fe7a76
|
@ -81,7 +81,7 @@ RCT_ENUM_CONVERTER(CKCameraZoomMode, (@{
|
||||||
@property (nonatomic) AVCaptureFlashMode flashMode;
|
@property (nonatomic) AVCaptureFlashMode flashMode;
|
||||||
@property (nonatomic) CKCameraFocushMode focusMode;
|
@property (nonatomic) CKCameraFocushMode focusMode;
|
||||||
@property (nonatomic) CKCameraZoomMode zoomMode;
|
@property (nonatomic) CKCameraZoomMode zoomMode;
|
||||||
|
@property (nonatomic, strong) PHFetchOptions *fetchOptions;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
@ -94,6 +94,15 @@ RCT_ENUM_CONVERTER(CKCameraZoomMode, (@{
|
||||||
NSLog(@"dealloc");
|
NSLog(@"dealloc");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
-(PHFetchOptions *)fetchOptions {
|
||||||
|
if (!_fetchOptions) {
|
||||||
|
PHFetchOptions *fetchOptions = [PHFetchOptions new];
|
||||||
|
fetchOptions.sortDescriptors = @[[NSSortDescriptor sortDescriptorWithKey:@"creationDate" ascending:NO]];
|
||||||
|
fetchOptions.fetchLimit = 1;
|
||||||
|
_fetchOptions = fetchOptions;
|
||||||
|
}
|
||||||
|
return _fetchOptions;
|
||||||
|
}
|
||||||
|
|
||||||
- (void)removeReactSubview:(UIView *)subview
|
- (void)removeReactSubview:(UIView *)subview
|
||||||
{
|
{
|
||||||
|
@ -424,15 +433,22 @@ RCT_ENUM_CONVERTER(CKCameraZoomMode, (@{
|
||||||
imageInfoDict[@"uri"] = temporaryFileURL.description;
|
imageInfoDict[@"uri"] = temporaryFileURL.description;
|
||||||
imageInfoDict[@"name"] = temporaryFileURL.lastPathComponent;
|
imageInfoDict[@"name"] = temporaryFileURL.lastPathComponent;
|
||||||
}
|
}
|
||||||
|
|
||||||
imageInfoDict[@"size"] = [NSNumber numberWithInteger:imageData.length];
|
imageInfoDict[@"size"] = [NSNumber numberWithInteger:imageData.length];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (shouldSaveToCameraRoll) {
|
if (shouldSaveToCameraRoll) {
|
||||||
[self saveImageToCameraRoll:imageData temporaryFileURL:temporaryFileURL];
|
[self saveImageToCameraRoll:imageData temporaryFileURL:temporaryFileURL];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
PHFetchResult *fetchResult = [PHAsset fetchAssetsWithMediaType:PHAssetMediaTypeImage options:self.fetchOptions];
|
||||||
|
PHAsset *lastImageAsset = [fetchResult firstObject];
|
||||||
|
|
||||||
|
if (lastImageAsset.localIdentifier) {
|
||||||
|
imageInfoDict[@"id"] = lastImageAsset.localIdentifier;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (block) {
|
if (block) {
|
||||||
block(imageInfoDict);
|
block(imageInfoDict);
|
||||||
}
|
}
|
||||||
|
@ -550,7 +566,7 @@ RCT_ENUM_CONVERTER(CKCameraZoomMode, (@{
|
||||||
NSLog( @"Error occured while writing image data to a temporary file: %@", error );
|
NSLog( @"Error occured while writing image data to a temporary file: %@", error );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
NSLog(@"YOU ROCK!");
|
NSLog(@"Image Saved - YOU ROCK!");
|
||||||
}
|
}
|
||||||
return temporaryFileURL;
|
return temporaryFileURL;
|
||||||
}
|
}
|
||||||
|
@ -590,10 +606,7 @@ RCT_ENUM_CONVERTER(CKCameraZoomMode, (@{
|
||||||
|
|
||||||
}];
|
}];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
[self startFocusViewTimer];
|
[self startFocusViewTimer];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue