Check if battery charging status changes in real time Swift

ok, im sorry, i thought this forum was also for development related questions? ive tried implementing the StateDidChange thing, but i didnt get it to work, thats why im asking here. people have helped me with code in this forum previously