I am using the UIImagePickerController in two cases
In the first
Retrieve image URL:
- (void)processImage:(UIImage*)image type:(NSString*)mimeType forCallbackId:(NSString*)callbackId
{
__block NSString* localId;
// Add it to the photo library
[[PHPhotoLibrary sharedPhotoLibrary] performChanges:^{
PHAssetChangeRequest *assetChangeRequest = [PHAssetChangeRequest creationRequestForAssetFromImage:image];
localId = [[assetChangeRequest placeholderForCreatedAsset] localIdentifier];
} completionHandler:^(BOOL success, NSError *err) {
if (!success) {
NSLog(@"Error saving image: %@", [err localizedDescription]);
} else {
PHFetchResult* assetResult = [PHAsset fetchAssetsWithLocalIdentifiers:@[localId] options:nil];
PHAsset *asset = [assetResult firstObject];
[[PHImageManager defaultManager] requestImageDataForAsset:asset
options:nil
resultHandler:^(NSData *imageData, NSString *dataUTI, UIImageOrientation orientation, NSDictionary *info) {
NSURL *fileUrl = [info objectForKey:@"PHImageFileURLKey"];
if (fileUrl) {
NSLog(@"Image path: %@", [fileUrl relativePath]);
} else {
NSLog(@"Error retrieving image filePath, heres whats available: %@", info);
}
}];
}
}];
}