Hello dinura128,
Thanks for posting in Apple Support Communities!
It sounds like when charging your device, you're seeing a liquid-detection alert on your iPhone. We'd like to help.
Take a look at If you see a liquid-detection alert on your iPhone. Has you device been in contact with liquid? If so, follow the steps under "If your iPhone or Lightning accessory is wet."
If your device has not been in contact with liquid or is not wet, have you tried other cables? "If you see this alert every time you connect a certain cable or accessory, that cable or accessory might be damaged. Contact the manufacturer.
If you see this alert every time you connect an Apple Lightning cable or accessory, contact Apple Support."
Have a nice day.