Merge pull request #202 from petros9282/master

FIX: photo library permission on iOS
This commit is contained in:
Ran Greenberg 2018-11-27 10:31:58 +02:00 committed by GitHub
commit 7f1df28583
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 23 additions and 27 deletions

View File

@ -526,27 +526,25 @@ RCT_ENUM_CONVERTER(CKCameraZoomMode, (@{
capturedImage = [UIImage imageWithCGImage:imageRef scale:capturedImage.scale orientation:UIImageOrientationUp];
imageData = UIImageJPEGRepresentation(capturedImage, 0.85f);
[PHPhotoLibrary requestAuthorization:^( PHAuthorizationStatus status ) {
if ( status == PHAuthorizationStatusAuthorized ) {
NSMutableDictionary *imageInfoDict = [[NSMutableDictionary alloc] init];
NSURL *temporaryFileURL = [CKCamera saveToTmpFolder:imageData];
if (temporaryFileURL) {
imageInfoDict[@"uri"] = temporaryFileURL.description;
imageInfoDict[@"name"] = temporaryFileURL.lastPathComponent;
}
imageInfoDict[@"size"] = [NSNumber numberWithInteger:imageData.length];
if (capturedImage && [capturedImage isKindOfClass:[UIImage class]]) {
imageInfoDict[@"width"] = [NSNumber numberWithDouble:capturedImage.size.width];
imageInfoDict[@"height"] = [NSNumber numberWithDouble:capturedImage.size.height];
}
if (shouldSaveToCameraRoll) {
NSData *compressedImageData = UIImageJPEGRepresentation(capturedImage, 1.0f);
NSMutableDictionary *imageInfoDict = [[NSMutableDictionary alloc] init];
NSURL *temporaryFileURL = [CKCamera saveToTmpFolder:imageData];
if (temporaryFileURL) {
imageInfoDict[@"uri"] = temporaryFileURL.description;
imageInfoDict[@"name"] = temporaryFileURL.lastPathComponent;
}
imageInfoDict[@"size"] = [NSNumber numberWithInteger:imageData.length];
if (capturedImage && [capturedImage isKindOfClass:[UIImage class]]) {
imageInfoDict[@"width"] = [NSNumber numberWithDouble:capturedImage.size.width];
imageInfoDict[@"height"] = [NSNumber numberWithDouble:capturedImage.size.height];
}
if (shouldSaveToCameraRoll) {
[PHPhotoLibrary requestAuthorization:^( PHAuthorizationStatus status ) {
if ( status == PHAuthorizationStatusAuthorized ) {
NSData *compressedImageData = UIImageJPEGRepresentation(capturedImage, 1.0f);
[CKGalleryManager saveImageToCameraRoll:compressedImageData temporaryFileURL:temporaryFileURL block:^(BOOL success) {
if (success) {
NSString *localIdentifier = [CKGalleryManager getImageLocalIdentifierForFetchOptions:self.fetchOptions];
@ -562,15 +560,13 @@ RCT_ENUM_CONVERTER(CKCameraZoomMode, (@{
//NSLog( @"Could not save to camera roll");
}
}];
} else if (block) {
block(imageInfoDict);
}
}
}];
}];
} else if (block) {
block(imageInfoDict);
}
CGImageRelease(imageRef);
}
else {
} else {
//NSLog( @"Could not capture still image: %@", error );
}
}];