I want to take screenshots of any running app, while my app is in the background.
I know I can take screenshots in iOS using:
UIGraphicsBeginImageContext(webview.frame.size);
[self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
UIImageWriteToSavedPhotosAlbum(viewImage, nil, nil, nil);
But this is not really possible in a background task as UIGraphicsGetCurrentContext returns NULL and I want a screenshot of the running app and not my view. Is there any other way?
Recording the screen from a background app seems to be possible, but not without jailbreaking your device. If you really need this capability for testing, you may find jailbreaking to be worth the hassle, but it's certainly not something you could include in an app that you plan to sell through the App Store.
When running the stock OS, the iOS app security sandbox will prevent your app from having access to the contents of the view of any other app.
For security reasons, you will not be able to that.
I hope