I am trying to acquire the surface associated with the main screen of the ios device, create an image out of it and save it. This is in relevance to this question - Ta
I remember I saw something on this subject (taking screenshots in the background) some time ago. I wasn't able find exact place and code which I saw. The only note which I left for myself was usage of createScreenIOSurface
I googled a little bit and found couple of mentions:
Get a screenshot while App is in background? (Private APIs allowed)
https://github.com/rpetrich/FastBlurredNotificationCenter/blob/master/Tweak.x
http://pastie.org/pastes/3734430
As I remember the code was way more compact then what you showed.
The specified code works if you run it in the background. It does take screenshot of the topmost surface on the display of iOS device.
The problem faced was due to the fact that inside the app, it was taking screenshot of the blank view created for the app.
However, you have to take the screenshots at minimum intervals of 2 sec otherwise the OS suspends your app. Any suggestions on how to improve that will be helpful.