I get that message with my cable and sometimes it won’t charge at all.
1. Try a different cable and charger, ideally Apple or MFi-certified ones. Cheap cables are the usual cause. 2. Look inside the Lightning port with a torch. Pocket lint gets packed in and stops the cable seating. Gently clean it with a wooden toothpick (not metal). 3. Restart the iPhone. If it happens with every cable after cleaning, the port may be damaged or wet; let it dry fully and if it continues, get it checked.