(most of the following information comes this page on Apple’s support website)
Many of the latest Apple and Samsung phones released in the last few years are rated either IP67 or IP68. The first digit in the rating is the rating of resistance to dust. The second applies to liquids.
iPhone XR, iPhone X, iPhone 8, iPhone 8 Plus, iPhone 7, and iPhone 7 Plus have a rating of IP67 under IEC standard 60529 (maximum depth of 1 meter up to 30 minutes).
iPhone XS and iPhone XS Max have a rating of IP68 under IEC standard 60529 (maximum depth of 2 meters up to 30 minutes)
These ratings are not a guarantee. Apple says liquid damage is not covered under warranty.
Don’t do the following:
Swimming or bathing with your iPhone
Exposing your iPhone to pressurized water or high velocity water, such as when showering, water skiing, wake boarding, surfing, jet skiing, and so on
Using your iPhone in a sauna or steam room
Intentionally submerging your iPhone in water
Operating your iPhone outside the suggested temperature ranges or in extremely humid conditions
Dropping your iPhone or subjecting it to other impacts
Disassembling your iPhone, including removing screws
Minimize exposing your iPhone to soap, detergent, acids or acidic foods, and any liquids—for example, perfume, insect repellent, lotions, sunscreen, oil, adhesive remover, hair dye, and solvents. If your iPhone comes into contact with any of these substances, follow the instructions to clean your iPhone.
If it gets wet, do the following:
To dry your iPhone, tap it gently against your hand with the Lightning connector facing down to remove excess liquid. Leave your iPhone in a dry area with some airflow. Placing your iPhone in front of a fan blowing cool air directly into the Lightning connector might help the drying process.