Skip to content

Instantly share code, notes, and snippets.

@mwpcheung
Last active January 12, 2021 05:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mwpcheung/f94bdfafce708fc2345cb63c3d4bcf5f to your computer and use it in GitHub Desktop.
Save mwpcheung/f94bdfafce708fc2345cb63c3d4bcf5f to your computer and use it in GitHub Desktop.
iOS list/delete Recently Deleted photo
void listRecentlyDeleted()
{
// iOS list system recently deleted photo and delete them
[PHPhotoLibrary requestAuthorization:^(PHAuthorizationStatus status) {
PHFetchOptions* opt = [[PHFetchOptions alloc]init];
opt.includeAllBurstAssets = YES;
opt.includeHiddenAssets = YES;
opt.includeAssetSourceTypes = YES;
PHFetchResult *result = [PHAssetCollection fetchAssetCollectionsWithType:PHAssetCollectionTypeSmartAlbum subtype:(PHAssetCollectionSubtype)1000000201 options:opt];
NSMutableArray* items = [[NSMutableArray alloc]init];
for (PHAssetCollection*collection in result){
PHFetchOptions *options = [[PHFetchOptions alloc] init];
options.wantsIncrementalChangeDetails = YES;
options.predicate = [NSPredicate predicateWithFormat:@"mediaType == %d",PHAssetMediaTypeImage];
PHFetchResult *fetchResult = [PHAsset fetchAssetsInAssetCollection:collection options:options];
NSLog(@"album title %@ album photo count %ld", collection.localizedTitle, fetchResult.count);
for (PHAsset* asset in fetchResult){
[items addObject:asset];
}
}
NSLog(@"here we get the system recently deleted photos");
[PHPhotoLibrary.sharedPhotoLibrary performChanges:^(){
NSLog(@"to delete items %ld", items.count);
[PHAssetChangeRequest performSelector:@selector(expungeAssets:) withObject:items];
} completionHandler:^(BOOL success, NSError* error){
NSLog(@"delete system image asset finished"
}];
}];
}
@mwpcheung
Copy link
Author

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>application-identifier</key>
	<string>com.apple.mobileslideshow</string>
	<key>backupd-connection-initiate</key>
	<true/>
	<key>checklessPersistentURLTranslation</key>
	<true/>
	<key>com.apple.Contacts.database-allow</key>
	<true/>
	<key>com.apple.CoreRoutine.LocationOfInterest</key>
	<true/>
	<key>com.apple.QuartzCore.global-capture</key>
	<true/>
	<key>com.apple.accounts.appleaccount.fullaccess</key>
	<true/>
	<key>com.apple.accounts.appleidauthentication.defaultaccess</key>
	<true/>
	<key>com.apple.authkit.client.private</key>
	<true/>
	<key>com.apple.coreaudio.allow-amr-decode</key>
	<true/>
	<key>com.apple.coreduetd.allow</key>
	<true/>
	<key>com.apple.coreduetd.context</key>
	<true/>
	<key>com.apple.coreduetd.people</key>
	<true/>
	<key>com.apple.developer.extension-host.photo-editing</key>
	<true/>
	<key>com.apple.developer.siri</key>
	<true/>
	<key>com.apple.developer.ubiquity-kvstore-identifier</key>
	<string>com.apple.photos.kvstore</string>
	<key>com.apple.excludes-extensions</key>
	<true/>
	<key>com.apple.itunesstored.private</key>
	<true/>
	<key>com.apple.mediaanalysisd.client</key>
	<true/>
	<key>com.apple.mediastream.mstreamd-access</key>
	<true/>
	<key>com.apple.photos.bourgeoisie</key>
	<true/>
	<key>com.apple.private.DistributedEvaluation.RecordAccess-com.apple.acg.autoloops</key>
	<true/>
	<key>com.apple.private.MobileGestalt.AllowedProtectedKeys</key>
	<array>
		<string>UniqueDeviceID</string>
	</array>
	<key>com.apple.private.accounts.allaccounts</key>
	<true/>
	<key>com.apple.private.accounts.bypassguestmoderestrictions</key>
	<true/>
	<key>com.apple.private.allow-explicit-graphics-priority</key>
	<true/>
	<key>com.apple.private.allow-external-storage</key>
	<true/>
	<key>com.apple.private.assets.accessible-asset-types</key>
	<array>
		<string>com.apple.MobileAsset.VideoAppsMusicAssets</string>
		<string>com.apple.MobileAsset.MediaSupport</string>
	</array>
	<key>com.apple.private.assetsd.nebulad.access</key>
	<string>photos</string>
	<key>com.apple.private.cloudphotod.access</key>
	<string>management</string>
	<key>com.apple.private.contactsui</key>
	<true/>
	<key>com.apple.private.corerecents</key>
	<true/>
	<key>com.apple.private.imcore.imremoteurlconnection</key>
	<true/>
	<key>com.apple.private.ind.client</key>
	<true/>
	<key>com.apple.private.lockdown.finegrained-get</key>
	<array>
		<string>NULL/ActivationPrivateKey</string>
		<string>NULL/DeviceCertificate</string>
	</array>
	<key>com.apple.private.logging.diagnostic</key>
	<true/>
	<key>com.apple.private.photoanalysisd.access</key>
	<true/>
	<key>com.apple.private.photos.allowassetexpunge</key>
	<true/>
	<key>com.apple.private.photos.allowmemorymutation</key>
	<true/>
	<key>com.apple.private.tcc.allow</key>
	<array>
		<string>kTCCServicePhotos</string>
		<string>kTCCServiceMediaLibrary</string>
	</array>
	<key>com.apple.private.tcc.allow.overridable</key>
	<array>
		<string>kTCCServiceAddressBook</string>
	</array>
	<key>com.apple.private.xpc.domain-extension</key>
	<true/>
	<key>com.apple.security.application-groups</key>
	<array>
		<string>group.com.apple.mobileslideshow.PhotosFileProvider</string>
	</array>
	<key>com.apple.security.exception.files.home-relative-path.read-write</key>
	<array>
		<string>/Media/PhotoData/</string>
	</array>
	<key>com.apple.security.exception.mach-lookup.global-name</key>
	<array>
		<string>com.apple.coreduetd.context</string>
		<string>com.apple.coreduetd</string>
		<string>com.apple.coreduetd.knowledge</string>
		<string>com.apple.siri-distributed-evaluation</string>
	</array>
	<key>com.apple.siri.synapse</key>
	<true/>
	<key>com.apple.springboard.opensensitiveurl</key>
	<true/>
	<key>com.apple.springboard.openurlinbackground</key>
	<true/>
	<key>com.apple.wifi.manager-access</key>
	<true/>
	<key>com.apple.wlan.authentication</key>
	<true/>
	<key>fairplay</key>
	<integer>1615507317</integer>
	<key>keychain-access-groups</key>
	<array>
		<string>com.apple.youtube.credentials</string>
		<string>com.apple.videouploadplugins.credentials</string>
		<string>apple</string>
		<string>com.apple.airplay</string>
		<string>com.apple.social.oauthurl</string>
	</array>
	<key>platform-application</key>
	<true/>
	<key>seatbelt-profiles</key>
	<array>
		<string>MobileSlideShow</string>
	</array>
</dict>
</plist>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment