I'm trying to get a notification 开发者_JAVA百科when iphone power off/switch off/ turn off. I want make a log file in which i'll be writing a timestamp of device when power off/switch off/ turn off occurs.
In your application delegate should be the methods:
- (void)applicationDidEnterBackground:(UIApplication *)application
- (void)applicationDidBecomeActive:(UIApplication *)application
you will also be notified when someone push the home button or switch the app.
//EDIT: if you generally want to log the power settings:
go to your iPhone settings and choose 'Developer Settings' (I think there have to be a developer profile installed). There you can enable 'Power Logging'
(the log file would be transferred to your XCode Organizer tool)
精彩评论