I'm making a turnbased game. To prevent users from cheat, the turn will automatically get passed to the opponent if the user close the app in the middle of a turn. This because so the user can't close the app, restart it, and beging the turn from the beginning.
There are two cases that should penalize the player however. If a phone call gets in, or the low battery warning appears. I can detect the phone call coming in and respond, but I don't know what to do with the battery?
Any suggestions would be awesome
Battery monitoring is enabled by setting to YES a property of the UIDevice
singleton:
UIDevice *device = [UIDevice currentDevice];
device.batteryMonitoringEnabled = YES;
iPhone OS
provides two type of battery monitoring events, one for when the state changes (e.g., charging, unplugged, full charged) and one that updates when the battery’s charge level changes. As was the case with proximity monitoring, you register callbacks to receive notifications:
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(batteryChanged:) name:@"UIDeviceBatteryLevelDidChangeNotification" object:device];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(batteryChanged:) name:@"UIDeviceBatteryStateDidChangeNotification" object:device];
ALso refer this link.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With