Apple's face-scanning tech should work with the vast majority of sunglasses. However, if you happen to own a pair of sunglasses that Face ID just doesn't work with, don't fret -- a simple change of settings should help.
Each time Face ID is used to unlock your phone, a combination of sensors invisibly project thousands of infrared dots onto your face, before matching these dots to your facial fingerprint, all in a fraction of a second. Most sunglasses still allow the infrared light through for Face ID to verify you are looking at your phone. However, if you happen to own sunglasses that block the specific IR light Apple uses with Face ID, each scan will inevitably fail.
You can either take your sunglasses off to use Face ID, or you can disable Face ID's attention detection requirement. Open Settings > Face ID & Passcode and scroll down to the Attention section. Slide the switch next to Require Attention for Face ID to the Off position and accept the warning.
With this feature turned off, Face ID will no longer require you to look at the screen or your eyes to be clearly open before it will unlock your device via Face ID. In turn, eliminating this requirement will allow Face ID to work with sunglasses that blocked Face ID from seeing your eyes.
If you're not comfortable with Face ID potentially unlocking your phone when you're not actively looking at the screen, then you're only other option is to find a different pair of sunglasses.
Apple - USE TAG
reading•Having trouble with Face ID and sunglasses? Try this
Oct 20•iPhone XR: Why the cheapest 2018 iPhone might be the one you want
Oct 20•iPhone XS specs vs. XS Max, XR, X: What's new and different
Oct 20•iPhone XR camera: Here’s how good we think it'll be
Oct 20•9 great reads from CNET this week