The general strategy is to the dry out the device both on the macro level (absorb any visible water) and use moisture grabbing compounds to prevent water droplets / vapor from damaging the electronic components. Turning off the phone and and placing the damaged device in an appropriate low humidity environment (ideally a vacuum chamber) as quickly as possible has the best odds of success.
Part 1. How to check if your iPhone is water damaged or not
Are you sure your iPhone is really water damaged? If not, you can check your iPhone’s liquid indicators to know the fact. iPhone and most iPod devices that were built after 2006 have built-in Liquid Contact Indicators that will show whether the device has been in contact with water or a liquid containing water. So when your iPhone has been exposed to water, you'll see a red dot. If not, congratulations! Your iPhone is not water damaged. You can check the red dot in the places as shown in the picture below.
Part 2. How to fix and dry out a water damaged iPhone for free
If your iPhone or other iOS device is water damaged, don’t worry, there are some ways to rescue it. If you are lucky, you may get iPhone/iPad/iPod back in working order soon. Just follow below guidance to fix your water damaged iPhone. (Indeed, the same principles will apply to most electronic devices.)
Step 1. Get the iPhone out of the water or other liquid right away. Don't be tempted to turn it on and check for damage, which can cause short circuits.
Step 2. Remove your SIM card from your iPhone. Wipe the excess and exterior water or other liquid off everything you can reach. Turn the iPhone upside down and give it a gentle shake to clear the ports and sockets. Don't be tempted to power it up and see if it still works.
Step 3. Deeper drying with rice or Silica gel sachets. Don't try to dry your water damaged iPhone with a hair dryer or other external drying machine. This can force water deeper into your iPhone or damage the iPhone's internal components. You should still give the iPhone at least 48 hours to dry out completely, however.
Step 4. Try to switch your iPhone on. Once you've waited a couple of days and think you've successfully dried out your iPhone, you can try switching it on. If your iPhone still doesn't work, or if you want to get the internals checked out, you will need Apple after-sales service to help you.