I’ve seen some other people facing this issue, and there are a couple of fixes that I figured will work.
First thing you should try is a force restart:
1. Press and quickly release the volume up button.
2. Press and quickly release the volume down button.
3. Press and hold the side button until your iPhone restarts and you see the Apple logo.
For a more advanced fix (in case force restart doesn’t work), you can try reinstalling your iOS using tools like ReiBoot or 3uTools. They work very well.
Lastly, if that doesn’t work either, it’s best to get in touch with Apple Support and see if it’s a hardware issue.