I’d be surprised if any phones used a magnetic compass, surely they get the compass bearing from the GPS?
Well, they don’t need a compass to get a positional fix as they use GPS to receive satellite signals to fix a position.
However many phones also have a compass or rather magnetometer sensor to work out the direction the phone is pointing relative to north. GPS position will just tell you where you are, not the direction you are facing.
Accelerometers give an indication of movement in a direction, if you are moving, but without the magnetometer it doesn’t know the direction relative to north. Combined with GPS it can work out the relative direction though, but still have to be moving.
Magnetometers are useful for augmented apps also to give overlaid data based on where you are pointing the phone.
You usually have to calibrate it by waving the phone about in a figure of eight to increase the accuracy.