uidevicebatterystatedidchangenotification not working sometimes
问题 I am trying to check if device's charging port is working fine. There are two scenarios - a. when the charging cable is already plugged in. b. when the charging cable is plugged in after sometime. For case a, on viewDidLoad() I checked for enable batteryStateMonitoring and checked the current state of the battery. - It always works. For case b, I tried using NSNotification s UIDeviceBatteryStateDidChangeNotification override func viewDidLoad() { UIDevice.current.isBatteryMonitoringEnabled =