The Phone checks for unwanted resistance on two of the pins on the usb-c charge connector on the phone. If there is water or too much moisture present in the connector, it will trigger a warning/audio beep - and disable charging.
The water present check is performed when charger is inserted.
Salt water, or water with clorine is absolutely not good for the connector. Should it happen - DO NOT CHARGE VIA THE CONNECTOR. clean and dry it before charging. This can save the connector/phone.