当我们的应用程序在后台时,是否可以快速检查电池电量?检查背景中的电池电量?
目前我正在使用一个iOS应用程序,当电池电量达到30%时,系统将通知用户系统通知。
我试过了,我收到了随机通知,有时是4%,有时是10%,移动比以往任何时候都多30%。
func applicationDidEnterBackground(application: UIApplication) {
if(UIDevice.currentDevice().batteryLevel <= 0.30 && UIDevice.currentDevice().batteryState != UIDeviceBatteryState.Charging)
{
Notification.addNotificationSystem("Mettre le portable à charger", fireDate: 1, iconBadgeNumber: false)
}
}
}
您的应用程序被暂停在后台运行,所以你不能指望定期醒来并检查电池状态。 –