Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

moonman239

Cancelled
Original poster
Mar 27, 2009
1,541
32
I think I have a solution. If the app delegate's applicationWillResignActive is called, but not its applicationDidEnterBackground method, and the app supports multitasking, then the device is locked.

Note: This solution only works if the user locks the device from the app.
 
What is the reason for this? What do you want to achieve ?

For me, where this came up it was about testing the power/lock button.
I had to detect if this button was pressed. I did this by checking the brightness before the app went to background, and when it came back.
 
What is the reason for this? What do you want to achieve ?

For me, where this came up it was about testing the power/lock button.
I had to detect if this button was pressed. I did this by checking the brightness before the app went to background, and when it came back.

I want to create an app that gathers battery usage stats. I'd like the app to know if the device is locked, but I see the app cannot do this without using a private API if the app is not in the foreground.
 
I want to create an app that gathers battery usage stats. I'd like the app to know if the device is locked, but I see the app cannot do this without using a private API if the app is not in the foreground.

You are right about that.
Im working for a company which is the heart of apple in at least the benelux

I make apps and scripts for the companies quality and efficiency. Also for testing devices I contacted apple diagnostics and director developer engineer about this. The only answer I get is, this is private framework and only for apple diagnostica team to use and so we will not help or give you a basic documentation

Im sorry, i wish i cud help you however if i cud i wud do it in pm if its worth
 
You are right about that.
Im working for a company which is the heart of apple in at least the benelux

I make apps and scripts for the companies quality and efficiency. Also for testing devices I contacted apple diagnostics and director developer engineer about this. The only answer I get is, this is private framework and only for apple diagnostica team to use and so we will not help or give you a basic documentation

Im sorry, i wish i cud help you however if i cud i wud do it in pm if its worth

Thanks.

The basic idea is this: Gather some battery usage stats that will allow the user to know if his battery usage is normal. If he seems to get abnormally low usage, then he ought to know so that he can have someone determine whether or not he needs a new battery.
 
Im not sure if its gonna be of any use
But I got something where you can get info from the battery. Designed capicity, current capacity max capacity charge cycles etc etc etc

Just let me know in pm
P.s. Still private
 
Why PM? Other people might want to know as well

To get battery level:

Code:
[[UIDevice currentDevice] setBatteryMonitoringEnabled:YES];
float batteryLevel = [[UIDevice currentDevice] batteryLevel];

The code above is documented and will not get rejected by Apple. Now its up to you to make statistics and stuff. If you want anything more accurate than that, google has plenty of examples for jailbroken devices with all sorts of whistle and bells, but are going to get rejected by apple, in fact, xcode itself will reject and not let you submit your app.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.