Skip to content

Commit

Permalink
Fix CameraKitGallery to return valid imageuri (#278)
Browse files Browse the repository at this point in the history
* Fix CameraKitGallery to return valid imageuri
- If PHImageFileURLKey does not exist, use PHImageFileUTIKey instead

* syntax fix
  • Loading branch information
RyanCommits authored and gran33 committed Oct 21, 2019
1 parent e76b190 commit 7ab6997
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions ios/lib/ReactNativeCameraKit/CKGalleryViewManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -861,6 +861,11 @@ +(NSMutableDictionary*)infoForAsset:(PHAsset*)asset
[[PHCachingImageManager defaultManager] requestImageDataForAsset:asset options:imageRequestOptions resultHandler:^(NSData * _Nullable imageData, NSString * _Nullable dataUTI, UIImageOrientation orientation, NSDictionary * _Nullable info) {

NSString *fileName = ((NSURL*)info[@"PHImageFileURLKey"]).lastPathComponent;

if (!fileName) {
fileName = ((NSURL*)info[@"PHImageFileUTIKey"]).lastPathComponent;
}

fileName = [CKGalleryViewManager handleNonJPEGOrPNGFormatsFileName:fileName dataUTI:dataUTI];
imageData = [CKGalleryViewManager handleNonJPEGOrPNGFormatsData:imageData dataUTI:dataUTI];

Expand All @@ -869,6 +874,10 @@ +(NSMutableDictionary*)infoForAsset:(PHAsset*)asset
UIImage *compressedImage = [UIImage imageWithData:imageData];

NSURL *fileURLKey = info[@"PHImageFileURLKey"];

if (!fileURLKey) {
fileURLKey = info[@"PHImageFileUTIKey"];
}

if (fileURLKey) {

Expand Down

0 comments on commit 7ab6997

Please sign in to comment.