Restart or soft reset your phone
Do Factory reset
Try adding a magnet to your phone case
Contact Apple support
Bring your iPhone to an authorized technician
Replace your iPhone camera
Replace your phone case
Perform some quick software fixes
Clean your rear camera’s lens
For More info
Click Here