i want to save image into photo library of iphone sdk. my image is coming from one url and that url is coming from APNS. basically i want save image directly into iphone lib without opening app when user will click on that URL which is coming as Push notification. right now i am doing this as follows but i dont want to show that image i just want to save.
-(void) sshowansimage:(NSString *) strImageURL
{
NSURL *imageURL = [NSURL URLWithString:strImageURL];
NSLog(@"coming URL is %@", strImageURL);
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0), ^{
NSData *imageData = [NSData dataWithContentsOfFile:strImageURL];
[self performSelectorOnMainThread:@selector(showImage:) withObject:imageData waitUntilDone:YES];
});
}
-(void)showImage:(NSData*)imageAsData
{
NSLog(@"IN image view mthhod data is %d",imageAsData.length);
ansinage.image = [UIImage imageWithData:imageAsData];
}
Use below code for store image directly to Photo Album
UIImage *image=[UIImage imageWithData: imageData];
UIImageWriteToSavedPhotosAlbum(image, nil, nil, nil);