Detect screenshots taken ON ANY APP within my iOS app - ios

Is it possible to detect when the user takes a screenshot in any app while my app is in the background ? And how would I do that ?
If not, can I background check regularly for screenshots (not pictures from the camera) in the photo library ? Like every minute or hour ?

One way to get your app to detect Screenshots is:
Register with the Photo Library's PHPhotoLibraryChangeObserver
When your app receives a notification that a photo has been added,
check its PHAssetMediaSubtype
If the Subtype is PHAssetMediaSubtypePhotoScreenshot, you know a new
Screenshot has been taken.
The PHPhotoLibraryChangeObserver protocol notifies you of changes that
occur in the Photos library, regardless of whether those changes are
made by your app, by a user in the Photos app, or by another app that
uses the Photos framework.
https://developer.apple.com/reference/photos/phphotolibrarychangeobserver

Related

How to take a screenshot programmatically if the app is running in background

I am writing a piece of code using swift for iOS.
It’s using location services. I need to take a screenshot of the current screen every time the location gets updated.
The thing is when the app is running in background and updating the location the screenshots taken are from my app. Not the app which is currently available in the screen.
Assume that the user plays a game in their phone. But my app run in background and updating the location when the users location is significantly changed the screenshot should be taken and it should include the game. Not my app screen.
Can some one tell me how to achieve the screenshot capability I want.
Short answer: You can't.
Apps can only take screenshots of their own content. Starting with (I think) iOS 7 Apple blocked the ability of apps to take screenshots of anything but their own content. This is for security reasons.
Imagine your app echoes each character of your password as you type it, and then replaces it with a bullet as you type the next character. Now imagine an app that runs in the background and takes a screen-shot every time your app displays a new character of the user's password.

How to programmatically control iPhone or device speaker in iOS

I am creating a conference app for iOS 9, which makes a call. Once call is made it takes user to native iPhone screen. Later user can come back to our app to do various tasks, when call is running in background. We need to give a user option to control that iPhone speakers On/Off from our app itself.
But unfortunately, we are not able to find any document or sample on ths.
Kindly advice us how to achieve ths functionality.

How can I detect if a photo has already been imported to a photo album?

I've got an app that copies screenshots from another device onto an iOS device and adds them to a photo album, using [ALAssetsLibrary assetForURL] and [ALAssetsGroup addAsset]. But every time I do this it adds the screenshots even if they've been added previously. Is there a way of knowing whether I've previously imported an image? I can't use the filename because the screenshots use a simple index that gets incremented.

iOS local notifations on new pictures in gallery

I would like to show a badge on my app icon when new pictures are taken on the phone stock camera.
How can I register for this event? If not possible , is there a way to tell when iCloud of the user added new photos and get notify the user to open the application?
If not can I schedule an event to the user (lets say every hour) and run some code to check if pictures were added to the gallery - if so display a badge so the user will open my app?

ALAssetsLibrary ask user for permission when saving to an album? Why?

I have a game where users can take a screen shot and it will save it to a custom album named after the game. When I try and do this, iOS asks the user if the App can have access to their location information, if they say no, then the screen shot is not saved in the custom album, but rather the default album.
Why is it asking permission to use location information? I'm just taking a screen shot. It has nothing to do with the camera. I'm just copying the opengl surface and making a UIImage out of it.
This is how I'm saving the UIImage:
- (void)writeImageToSavedPhotosAlbum:(CGImageRef)imageRef orientation:(ALAssetOrientation)orientation completionBlock:(ALAssetsLibraryWriteImageCompletionBlock)completionBlock;
Is location information being put into the screen shot? If so, can I disable that so this warning doesn't come up? My game has no need for location information and I'd hate for users to think I'm tracking them.
This seems like a crazy warning since it's completely factually wrong.
As shown in the following link,
http://developer.apple.com/library/ios/#Documentation/AssetsLibrary/Reference/ALAssetsLibrary_Class/Reference/Reference.html
This method will fail with error
ALAssetsLibraryAccessGloballyDeniedError if the user has not enabled
Location Services (in Settings > General).
However, we have found that there is not location permission request in iOS 6. Maybe iOS 6 has other privacy control on Photos. So you don't need to asking location permission. Our solution is check the [[UIDevice currentDevice]systemVersion] and only save to custom album while iOS >= 6.

Resources