Phone compasses are not highly reliable. They should be calibrated before use and are not a substitute for a real compass. Search the internet for calibration instructions suitable for your phone.
Without regular calibration, a phone compass can be totally unreliable, and even with calibration they are often only accurate to +/- 45 degrees.
With that proviso, the built-in compass functions work adequately for simple needs and are used to tag photographs with the direction in which the camera was facing at the time of the photograph.