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
Nov 20•The best Black Friday 2018 deals on Apple products: Free iPhone XR, $250 HomePod, $100 off Apple Watch, $50 off AirPods
Nov 20•Black Friday 2018 smartwatch and fitness tracker deals: $80 off Apple Watch, $200 Samsung Gear S3, $150 Fitbit Versa
Nov 20•iPhone XS: Here's how it looks under the macro lens
Nov 20•Steam Link hardware faces permadeath