If the iPhone has been exposed to liquids, unplug all cables and do not charge the device until it is completely dry. Using accessories or charging it when it's wet can damage your iPhone. Wait at least 5 hours before charging it with a Lightning or USB-C cable or connecting an accessory. Most people don't know this, but putting the iPhone in a place where it dries with rice can cause more problems, as small particles of broken rice or outer enamel or starch can block speaker grilles and form a line around the iPhone.
This is the official IP rating of iPhones, as mentioned on their respective technical specifications pages of Apple support. If your iPhone comes into contact with any of these substances, follow the instructions to clean it. Thanks to waterproofing, you can expect your iPhone to work well after its dive, but if you have any problems with your iPhone in the future, the incident may come back to haunt you. However, if your non-waterproof iPhone fell into the water or if your waterproof iPhone was submerged in liquid for a long time, you should follow almost all of the tips mentioned here.