IOS 低电量提示如何应对?

How to respond to low power prompt in IOS?

我确定以前有人问过这个问题,但我似乎找不到它,而且我不确定如何重新措辞。

In IOS 9+ 当电量变低时 iOS 会提示您选择进入低电量模式。

我希望能够在看到此警报时暂停我的应用程序中的 activity。

我确定有一个我可以使用的委托方法。有人知道它的名字吗?

谢谢!

注意 NSProcessInfoPowerStateDidChangeNotification,如 React to Low Power Mode on iPhones 中所述。当您收到该通知时,请检查状态:

Once your app is notified of a power state change, it should then query isLowPowerModeEnabled to determine the current power state...

Your app can query the current power state at any time by accessing the isLowPowerModeEnabled property of the NSProcessInfo class, as shown in Listing 7-2. This property contains a boolean value, indicating whether Low Power Mode is enabled or disabled.

或者您正在寻找

- (void)applicationWillResignActive:(UIApplication *)application
{
    // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
    // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}

在您的主程序中 AppDelegate.m 每当显示任何系统弹出窗口时都会调用它。