Is it possible to retrieve data from the Settings App? - ios

Is it possible to access the data contained within the Battery view inside of the Settings App. More specifically, I am interested in the amount of time that has been spent on screen for each application.

I saw this app as well and was wondering how it works so I downloaded the app and the Moment app actually uses as notification to prompt you to screenshot the battery life each day which I assume it then uses OCR to read the data from the screenshot.
See attached images for the detailed app flow.

Not really, the information you want are from Private API's and unfortunately apple doesn't allow it.
But you can get some basic information and notifications related to battery settings like:
Battery State
Battery Percentage Level
Battery Monitoring - Enabled / Disabled
For more reference check this Link.

Related

Apple disallowing background location tracking which is critical to business use case

We have an app that tracks riders in the field and as per their current location and some other parameters assign them deliveries. For this, even when the user is not currently using the app, background mode or device locked, we need to keep track of their location after every x seconds.
Now, we have explained the complete business use case to Apple but they keep coming back with the same response:
Thank you for information. We still need a demo video that shows a
“Background Location” feature (Such as: turn-by-turn navigation,
bread-crumbing) when the app runs in the background.
We still do not see a “Background Location” feature (Such as:
turn-by-turn navigation, bread-crumbing) within your app in the demo
video your provided. If the app does not have this feature, please
kindly use the foreground location instead. please remove the
“location” setting from the UIBackgroundModes key if your app does not
require persistent real-time location updates. You may wish to use the
significant-change location service or the region monitoring location
service if persistent real-time location updates are not required for
your app features.
I wonder how does Uber and other ride sharing/location based apps go around this app for their drivers
You haven't really asked a question above (likely why someone downvoted). You've mostly just posted a complaint about Apple's review process. You've not explained why it's critical to get it every few seconds. And you haven't mentioned why Apple's suggestions don't work/aren't good enough.
Here are some general points around the area you have mentioned that should be useful
Background location:
If you want to allow your app users to close your app, you can use "significant-change location service" to allow your app to detect when the device has moved a lot, in a much more battery efficient way. You get ~10 seconds to ping a server and restart the request for the next time. Apple mentioned this in their response to you, please check it out: https://developer.apple.com/library/archive/documentation/UserExperience/Conceptual/LocationAwarenessPG/CoreLocation/CoreLocation.html
"I wonder how does Uber and other ride sharing/location":
They don't do what you are trying to do first of all, they encourage their drivers to keep the app open at all times for optimal performance. Again Apple mentioned this in their response. Your app is not providing any use to the app user while in the background and tracking location. So either keep the app open and track location (How to prevent screen lock on my application with swift on iOS) or, rely on significant change location events in the background
Again as Apple said in their response, if 1 or 2 above doesn't address your needs (likely they do), you need to implement a feature such as turn by turn directions in the background, in order to justify why you need this data. Users also need the ability to turn this off, so that it can't be abused by the developers.
Apple doesn't allow apps to just track whatever they want due to privacy issues. There is no way to get around this, you'll have to do one of the above.

I need to check if user open a facebook or whats app during driving

I need to crate app, one of it is features to check if user is using Facebook or whats App during driving is it doable.
For privacy matters, Apple does not allow iOS apps to access other application's data, such as when the user enters them and other "sensitive" data of that sort. So, the simple answer is that you cannot do that. Another App's usage is undeterminable as of now on iOS.
Either way. Even if iOS apps are allowed to fetch data from other apps, you have to make sure your app is running on background and checking. iOS manage memory itself and kills app in background automatically. So the app is not practical. Plus if you constantly check the speed in background, the battery life will decrease.
But again on the first hand as other answers, your app does not allowed to access data. So this is not doable.
It is not possible , as apple does not allow iOS Apps fetching or accessing other apps data. Thanks

Is using Core Location for performing functionality in the background appropriate?

Lately, I've notice that there are a few applications request to access the user's location for performing some functionalities in the background.
For example: Application for scanning and uploading the user's photos for backup purposes, so when entering the background state, it keeps scanning and uploading.
What am I asking:
If there are Background Execution mechanisms for executing Background Tasks (Select Target -> Capabilities -> Background Modes), so why using the Core Location for doing such a thing?
If using Core Location is different, what is the benefit of using it?
Also, I've read (and this is what I assume) that using the core location for not what is meant should causes to let the application to be rejected, the weird thing that -as I mentioned- there are a few applications doing this! I feel a little confused about it.
Also, I've read (and this is what I assume) that using the core location for not what is meant should causes to let the application to be rejected, the weird thing that -as I mentioned- there are a few applications doing this! I feel a little confused about it.
You are right to be in doubt. Do not imitate this behavior. These people are misusing CoreLocation as a way of getting their code to run in the background even though they are not really using any CoreLocation features.
You are not allowed to do things arbitrarily in the background — and with good reason. Don't violate the rules. If you want to keep uploading even when in the background, use a URLSession with a background URLSessionConfiguration. Do things the right way.
Edit: To remove any doubt: I do not recommend the following approach, in fact, like #matt I highly discourage anyone from using this or a similar approach. Please see my comment below for a better way to update the app in the background.
To answer the OP question:
You can ask CLLocationManager to get significantLocationChanges. This will not only notify you and give you CPU time in the background, but will actually launch your app (even after phone restart!) to let you know of the location changes.
This is a pretty good way of promising yourself some extra processing time in the background (although like you said - it's a very bad "app behavior" and may even cause your app to get rejected from the AppStore)
AFAIK the first app to do this was Dropbox - they had a whole screen in settings explaining why they ask you for location just to backup your images... since iOS doesn't have any event (for 3rd party devs) for informing an app on changes in the device photos, Dropbox solution was to get "woken" on those location changes and check themselves for changes, if they found any - they would upload the new images to Dropbox in the background.
significantLocationChanges only uses low-power methods such as cellular towers and nearby Wifi and therefore is pretty easy on the battery. The processing itself however can be intensive, depending on the app that takes advantage of this method.

Can I find out the location of an app's icon on the home screen?

Is is possible to dynamically figure out the position of an app's icon on the home screen of an iphone/ipad?
Sorry I don't have enough credit to comment yet so I'm posting here.
To my knowledge no you cannot natively or easily do this. I know of no open source or other libraries. The reason being that your app exists in its own world, it is not in touch per say with the rest of the device. It can get permissions to read and write data but it doesn't know of itself.
Does that make sense?
When you open a website it cannot know which tab it is in the browser. Instead it knows how it was accessed and what device (physically) is using it. It knows the user-agent, the time, the browser, etc because that is information sent to it in the request. In turn the phone on launch gives data to the app in how to handle it but not for example how many other apps are running, or where it is on the screen. It's not normally considered relevant to run time. In addition it's a security feature in preventing an app from deleting or altering other apps, as well as itself. If you have an iPhone you will notice that SIRI cannot turn off google maps navigation or any other non-apple specific app. Only apps natively comparable and private party ones (ex apples) are accessible because Apple did that intentionally. They all know of their own existence and each others. However non-native in the sense of apps that do not come preinstalled and manufactured by the company creating the device are less trustworthy, in addition there are no guarantees about how they will be run by the device, where they will be, or what other apps will be there.
It is true that an app can request for another app it may be comparable with but it is up the user to handle that information.
May I ask for curiosities sake why you are trying to do this? Are there any other workarounds?
However in terms of it being physically possible, yes. I doubt that apple allows independent developers to do this however. But an example of this occurring may be gridlock where a user can move their apps around differently on the screen. The app in this case has the ability to access app position. But I believe in this case app position is about the UI and not about nested files. apps cannot to my knowledge modify information outside of their own file. Imagine if you had an app that could edit other games scores.
It is not possible to dynamically find out the position of an app's icon on the Home Screen (even for jailbreak apps). Apple wants you to respect the user's privacy settings.
Extra Info - There is popular JavaScript library that adds a promo bubble to the bottom of your mobile web application, inviting users to bookmark the app to their device's home screen.

How does the 'Flock' iOS app detect when photos have been taken?

Flock is a reasonably new iOS app from the guys at Bump, which has an interesting feature. It somehow knows when photos have been taken by another app, notifies the user (in a notification center way), and asks the user to share them into an album. There are other interesting features of course, but I'm particularly interested in this feature for another app that I'm working on.
I can't see how the API facilitates this directly. I looked carefully through the notifications API documentation, and apps can certainly register to show a notification to the user at a future date/time, and thus be opened by the user at that time... but I couldn't find any system notification for when a photo has been taken. The notifications API also allows server-generated notifications, but once-again, I don't know how Flock's server-side could know when the user has taken a photo in a different application.
I installed the app a couple of days back, and I only seem to get the notification when I have taken photos. It doesn't appear to be just a daily reminder.
Any ideas how Flock (and potentially other apps) manage to do this?
After a couple of days of observing the app's behaviour (and a lot of Googling and bumping into arcane discussions about file locking), I have a strong suspicion of how it works: Flock has simply registered for Significant-Change Location Service, which wakes the app and provides a small processing window when the user changes location. The documentation says:
At wake-up time, your app is put into the background and given a small amount of time to process the location data
I suspect that Flock is checking the image library at that point, and triggering a local notification if photos have been added. This squares with my experience that Flock gives me a local notification ~10 minutes after I leave home... which, in case any of the Bump/Flock devs are reading this, is just about the worst time for me to sort through my photos and share them in an album (perhaps I should use public transport more often).
There are some other interesting SO answers here, here and here... but for the most part they discuss local notifications (which can only be scheduled for a particular time, and will always alert the user at that time, so aren't really background tasks) or the 600 second background processing window afforded to apps that have been shut down by the user (which is certainly a background task, but is clearly not fit for the purpose of running a background task once a day or somesuch).
The Bump devs have also provide some clues to the underlying architecture of the app here.
I haven't used this Framework personally, but I did stumble across this documentation when doing research for a client.
Apple Photos Framework Reference
Under the Features & Concepts there is an entry for "Change Observing" which states:
Use the shared PHPhotoLibrary object to register a change handler for the photo entities you fetch. Photos tells your app whenever another app or device changes the content or metadata of an asset or the list of assets in a collection. PHChange objects provide information about object state before and after each change with semantics that make it easy to update a collection view or similar interface.
It appears that you can use the PHPhotoLibrary singleton to registerChangeObserver: on a class of yours (that adopts the PHPhotoLibraryChangeObserver protocol) to receive PHChange objects from the photoLibraryDidChange: method

Resources