The rapid development of built-in sensors in smartphones has inspired a variety of ubiquitous public navigation applications. Nevertheless, previous works have focused on vehicle and pedestrian navigation by smartphones, with limited research on shipboard navigation. In this contribution, we designed a multi-sensors fusion navigation algorithm that integrates the global navigation satellite systems (GNSS), inertial measurement unit (IMU), and magnetometer (MAG) to achieve high-precision horizontal positioning on shipboard for smartphones. Considering the changeable motion state of a ship and the setting of non-holonomic constraint (NHC) noise, a magnetometer-based turning detection method is proposed, and a NHC model with adaptive noise is constructed based on the turning detection results. We conducted a lake experiment in Taku Forts Lake, Tianjin, using sensor data collected from a Xiaomi MI8 through our self-developed ’Sensor Logger’ app. The experimental results demonstrated a high success rate of 94.22 % for magnetometer-based turning detection which can effectively detect turning motions. Compared to the traditional algorithm without constraint information, the roll, pitch and yaw accuracy improve by approximately 34.7 %, 17.9 %, and 57.9 %, respectively. Additionally, the position and velocity accuracy in the east and north directions improve to 0.0926 m, 0.1779 m, 0.0548 m/s, and 0.0589 m/s, respectively, representing enhancements of about 10.7 %, 7.4 %, 10.5 %, and 6.4 %. Overall, the proposed algorithm efficiently improves the shipboard navigation accuracy of smartphones, especially in terms of attitude accuracy.