These alerts can appear for a few reasons: Your iOS device might have a dirty or damaged charging port, your charging accessory is defective, damaged, or non Apple-certified, or your USB charger isn't designed to charge devices.
Why does my iPhone keep charging then Uncharging?
But what most people overlook is the build-up of dirt in your iPhone's charging port, and that prevents the cable from having a perfect connection inside the port. ... So if you're having issues with your iPhone constantly disconnecting from the charger, check if there are any clumps of dirt/lint.
Why does my iPhone charge intermittently?
Minor software errors are usually the main trigger of random charging system glitches. And the simplest solution to this would be a force restart. This helps clear out rogue apps and errant cached files that might have adversely affected the phone's charging system and cause the intermittent charging symptom.