I am developing a monitoring application for the iPad. It already uses private frameworks to send artificial events and simulate user input, while my App is on the background and another App on the foreground.
Now my problem is, I need to get a screenshot of the iPad as an image programatically. I know the UIGetScreenImage method, and also rendering every view on the screen to get the image. However, UIGetScreenImage cannot be called from the background. (I get an error telling me that when I try it from the background) And I cannot render the views from another App, since I only know my App's views.
OPTION 1 I am able to simulate a click on the home and lock keys, for the iPad to generate a screenshot. Afterwards, I use private APIs to access this image from the photoalbum, using the [PLPhotoLibrary](https://github.com/nst/iOS-Runtime-Headers/blob/3686717e107fa36a990fac20c30da2da9a25b698/PrivateFrameworks/PhotoLibrary.framework/PLPhotoLibrary.h ), PLPhotoAlbum and PLPhoto.
id lib = [PLPhotoLibrary sharedPhotoLibrary];
id allPhotosAlbum = [lib allPhotosAlbum];
id contents = [lib albumContents];
id lastPhoto = [contents objectAtIndex:[contents count] -1];
UIImage *screenshot = [lastPhoto newFullSizeImage];
The only problem with this approach is that the screenshots will stack up ont he album, filling the iPad's memory. So either I need another way, or I need a way to delete this pictures. But, when I call the delete methods in the photo album and photo library, I get a "SQLITE error 8 [attempt to write to readonly database]
Any suggestions on how to achieve this screenshot thing in a better way would be appreciated.
I will not be uploading this App to the App store. It is for private use.