Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Delete images in camera roll from code iOS

Is there a way to delete images (and videos) in camera roll in the photos app that my app didn't create. I know you can't delete things from Asset Library that your app didn't create. But this app isn't on app store. It's on a kiosk type environment. So I can use private APIs.

So is there a way to do this using private APIs that apple would not approve for the app store, but would work for my situation.

Thanks.

like image 716
hdsenevi Avatar asked Jan 13 '15 18:01

hdsenevi


People also ask

How do I remove Photos from iOS album?

To delete a single image from the Photos app, open the image and tap the Delete (trash) icon at the bottom right. Then tap Delete Photo.

Where do permanently deleted Photos go on iPhone?

Are my precious photos REALLY gone? If you're using Photos (not iPhoto), "deleted" images are held for about 30 days in the Recently Deleted album. If you "permanently" deleted them from that special album, they're gone for real. If you're really still using iPhoto, they would have been moved to iPhoto Trash.


1 Answers

Yep, you can do this in iOS 8 using Photos framework.

For example if you have Assets URLs stored in NSArray *assetsURLs

PHPhotoLibrary *library = [PHPhotoLibrary sharedPhotoLibrary];
    [library performChanges:^{
        PHFetchResult *assetsToBeDeleted = [PHAsset fetchAssetsWithALAssetURLs:assetsURLs options:nil];
        [PHAssetChangeRequest deleteAssets:assetsToBeDeleted];
    } completionHandler:^(BOOL success, NSError *error)
     {
         //do something here
    }];

this code will ask user to confirm removal from Camera Roll.

like image 190
Andrei Malygin Avatar answered Sep 23 '22 18:09

Andrei Malygin