I am using ALAssetLibrary to access camera roll. But it is getting all images, like what's App images, Facebook Image etc.
My code like this:
[_library enumerateGroupsWithTypes:ALAssetsGroupSavedPhotos usingBlock:^(ALAssetsGroup *group, BOOL *stop) {
if (group) {
[group setAssetsFilter:[ALAssetsFilter allPhotos]];
[group enumerateAssetsUsingBlock:^(ALAsset *asset, NSUInteger index, BOOL *stop) {
if (asset) {
//Getting photos here
}];
} } failureBlock:^(NSError *error) {
NSLog(@"Failed.");
}];
Is there any way to get only Camera capture photos using ALAssetLibrary ?
The only difference between camera captured photos and WhatsApp images is the EXIF Data.
You can read it out with
ALAssetRepresentation *representation = [asset defaultRepresentation];
NSDictionary *meta = [representation metadata];
or in Swift:
var representation = asset.defaultRepresentation()
var meta = representation.metadata()
This returns the following:
{TIFF}: {
DateTime = "2014:04:01 20:33:59";
Make = Apple;
Model = "iPhone 5";
Orientation = 3;
ResolutionUnit = 2;
Software = "7.1";
XResolution = 72;
YResolution = 72;
}, PixelWidth: 3264]
So you can check if Make is Apple, for WhatsApp images it is empty:
if([metaData["{TIFF}"]["Make"] isEqualToString: @"Apple"])
or in Swift:
if metaData["{TIFF}"]!["Make"] == "Apple"