Possible Duplicate:
How can i avoid Location service in AlAssetLibrary? Can i retrieve files using AlAssetLibrary without using Location Service?
Hi all, I am a newbie in iphone development and obj-c. i am using "ALAssetLibrary" in my Application to retrieve images from Photo Library. I identified that "ALAssetPropertyLocation"Property Key only available if location services are enabled for the caller. it is the key to retrieve the location information of the asset.But i am not using "ALAssetPropertyLocation"Property.i am using only ALAssetPropertyURLs.
whenever i am trying to deploy my Application in a new device there is a message box with the message "Location Service needed.." can i able to hide the "ALAssetPropertyLocation"Property?
I would really appreciate if someone could assist me in the correct way to approach my problem, and if possible any sample code to get my started.
Thank You In Advance :)
this is my Code:
//Getting image url from dictionary according to the user input
NSURL *imageurl = [dict objectForKey: [youSaid text]];
//Getting asset from url
typedef void (^ALAssetsLibraryAssetForURLResultBlock)(ALAsset *asset);
typedef void (^ALAssetsLibraryAccessFailureBlock)(NSError *error);
ALAssetsLibraryAssetForURLResultBlock resultblock = ^(ALAsset *myasset)
{
ALAssetRepresentation *rep = [myasset defaultRepresentation];
CGImageRef iref = [rep fullResolutionImage];
//Setting asset image to image view according to the image url
[imageview setImage:[UIImage imageWithCGImage:iref]];
};
ALAssetsLibraryAccessFailureBlock failureblock = ^(NSError *myerror)
{
NSLog(@"Error, cant get image - %@",[myerror localizedDescription]);
};
if(imageurl != nil)
{
ALAssetsLibrary *assetLibrary=[[ALAssetsLibrary alloc] init];
[assetLibrary assetForURL:imageurl resultBlock:resultblock failureBlock:failureblock];
}
enabling "location services "is a requirement for using the AssetsLibrary. The reason is that any photos/videos in the Photo-Library might contain geodata. This data is not just available through ALAssetPropertyURLs, but also if you read out the raw data from the asset (by using the getBytes:fromOffset:length:error: Method of ALAssetsRepresentation). Cause there is no way to strip the geo metadata from the raw image data (in case location services are disabled), I guess the design decision was made to make "location services" mandatory for using the AssetsLibrary.
This requirement might be confusing to the user. So you need to do 2 things:
1) If the user denies access to location services, then present a clear message while your app needs this access and that the app does not actually determine the current position or any GPS/data.
2) Display clear instructions how to enable location services, once the user has pressed "NO" on the initial dialog.
Cheers,
Hendrik
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With