<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Gustavo Emanuel Rosa</title>
    <description>The latest articles on DEV Community by Gustavo Emanuel Rosa (@gustavoem).</description>
    <link>https://dev.to/gustavoem</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4252576%2F167c2801-21fd-4266-bd67-ba21d92b8ba3.png</url>
      <title>DEV Community: Gustavo Emanuel Rosa</title>
      <link>https://dev.to/gustavoem</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/gustavoem"/>
    <language>en</language>
    <item>
      <title>A GPS timeout is not an answer</title>
      <dc:creator>Gustavo Emanuel Rosa</dc:creator>
      <pubDate>Thu, 19 Nov 2026 02:40:18 +0000</pubDate>
      <link>https://dev.to/gustavoem/a-gps-timeout-is-not-an-answer-4g5o</link>
      <guid>https://dev.to/gustavoem/a-gps-timeout-is-not-an-answer-4g5o</guid>
      <description>&lt;h2&gt;
  
  
  The question at the door
&lt;/h2&gt;

&lt;p&gt;A delivery app needs to know one thing at the door: &lt;strong&gt;is the courier at the address?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Most apps answer by comparing the last GPS reading with the address. That works in an open street. It fails in the places where deliveries really end: a garage, a lobby, a hallway. There the GPS can take long, or deliver nothing.&lt;/p&gt;

&lt;p&gt;I saw this up close in another kind of app: time clock apps, where an employee clocks in at the workplace. I had to investigate geolocation bugs where the location did not match where the phone really was. Sometimes the employee was inside the radius of the workplace, but the app showed them outside, or the other way around. It is the same question at a different door.&lt;/p&gt;

&lt;h2&gt;
  
  
  What a location library gives you when the GPS is slow
&lt;/h2&gt;

&lt;p&gt;I read the documentation of six React Native location libraries on 17 November 2026. When no reading arrives in time:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;four of them give your app a timeout error (&lt;code&gt;@react-native-community/geolocation&lt;/code&gt;, &lt;code&gt;react-native-geolocation-service&lt;/code&gt;, &lt;code&gt;react-native-background-geolocation&lt;/code&gt;, &lt;code&gt;react-native-get-location&lt;/code&gt;);&lt;/li&gt;
&lt;li&gt;one returns &lt;code&gt;null&lt;/code&gt; (&lt;code&gt;react-native-location&lt;/code&gt;);&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;expo-location&lt;/code&gt; documents no timeout option for &lt;code&gt;getCurrentPositionAsync&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These are good libraries, and this is the right behaviour for a library whose job is to give positions. But for the question at the door, an error is not an answer. Your app still has to decide: is a reading from 40 seconds ago still worth something?&lt;/p&gt;

&lt;p&gt;I wanted that decision in one place, so I wrote &lt;a href="https://www.npmjs.com/package/react-native-location-confidence" rel="noopener noreferrer"&gt;react-native-location-confidence&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  A report instead of a position
&lt;/h2&gt;

&lt;p&gt;The library does not give your app a position. It answers with a report:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nc"&gt;LocationConfidence&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="s1"&gt;'react-native-location-confidence'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nc"&gt;LocationConfidence&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;requestLocationPermission&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;report&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nc"&gt;LocationConfidence&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getProximityReport&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;destination&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;latitude&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mf"&gt;23.55052&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;longitude&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mf"&gt;46.633308&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;radiusMeters&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="n"&gt;report&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;evidenceRelation&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// 'supports_inside' | 'supports_outside' | 'inconclusive'&lt;/span&gt;
&lt;span class="n"&gt;report&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;qualityScore&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// 0 to 100: how good the evidence is. Not a percentage.&lt;/span&gt;
&lt;span class="n"&gt;report&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;diagnostics&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;reasonCodes&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// why, for example ['initial_fix_timeout', 'location_stale']&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The index says how good the evidence is. It is not a percentage and it is not a probability.&lt;/p&gt;

&lt;h2&gt;
  
  
  What happens when the GPS stays silent
&lt;/h2&gt;

&lt;p&gt;The call waits in steps: a first attempt of 4.5 seconds, then 7 seconds of extra time, 12 seconds in all by default. If nothing arrives, it uses the last reading it remembers, up to 60 seconds old.&lt;/p&gt;

&lt;p&gt;Then it works out how far the phone could be from that reading by now: the GPS error, plus the distance the phone could have moved since.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fj213q86w5iykbar9nt3h.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fj213q86w5iykbar9nt3h.gif" alt="Two phones lose the GPS signal at the same moment" width="640" height="696"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In this recording both sides lose the GPS at the same moment.&lt;/p&gt;

&lt;p&gt;On the left, nothing tells whether the phone moved. After about 13 seconds it could be more than 200 m away, and the answer becomes "the evidence cannot take a side".&lt;/p&gt;

&lt;p&gt;On the right, the phone reports that it is standing still. After 16 seconds the area is still 16 m wide, and the answer stays "the evidence supports inside the radius". (In this version only iOS reads the phone's activity.)&lt;/p&gt;

&lt;p&gt;So a timeout is a report with a lower index and a reason code. It is never an error.&lt;/p&gt;

&lt;h2&gt;
  
  
  One reading does not confirm itself
&lt;/h2&gt;

&lt;p&gt;The history of readings counts too:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The first reading, alone, keeps the index at 75 or less. Nothing confirms it yet.&lt;/li&gt;
&lt;li&gt;When the next readings agree with it, the index goes up to 97.&lt;/li&gt;
&lt;li&gt;A reading that lands 340 m away from the others in one second is not used.&lt;/li&gt;
&lt;li&gt;A reading that the system marks as simulated brings the index to 0 by default.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Why a C++ engine behind a TurboModule
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;One engine.&lt;/strong&gt; All the rules live in one C++17 engine. A Kotlin layer on Android and a Swift layer on iOS only collect the readings and hand them over. The two platforms give the same answer because they run the same code.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A typed border.&lt;/strong&gt; The library is a TurboModule (React Native's New Architecture). The contract between JavaScript and native code is generated from one typed file: one call goes in, one report comes out.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Tests without a phone.&lt;/strong&gt; The engine has no platform code, so its tests run on a laptop. It has 354 test cases today.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I chose C++ to have one implementation, not for speed. I have not measured performance, so I claim nothing about it.&lt;/p&gt;

&lt;p&gt;Building it, I understood better how the JVM works with JNI, the bridge that lets the Kotlin layer call the C++ engine.&lt;/p&gt;

&lt;h2&gt;
  
  
  What it is not, and what is missing
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;It is version 0.1.0. Besides the Android emulator and the iOS Simulator, it has run on one physical phone only: an Android phone (Samsung Galaxy J6, Android 10), indoors and standing still. Not tested yet: a physical iPhone, outdoors, and a GPS that really stays silent.&lt;/li&gt;
&lt;li&gt;The numbers behind the index (weights, speeds, limits) are design choices, not calibrated measurements.&lt;/li&gt;
&lt;li&gt;It is not proof of presence and it is not fraud detection. A location that is not marked as simulated proves nothing.&lt;/li&gt;
&lt;li&gt;It does not work in the background, it needs the New Architecture, and Expo Go cannot load it.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Try it
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm install react-native-location-confidence
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;npm: &lt;a href="https://www.npmjs.com/package/react-native-location-confidence" rel="noopener noreferrer"&gt;https://www.npmjs.com/package/react-native-location-confidence&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;GitHub: &lt;a href="https://github.com/gustavo-em/react-native-location-confidence" rel="noopener noreferrer"&gt;https://github.com/gustavo-em/react-native-location-confidence&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Comparison with the six libraries: &lt;a href="https://github.com/gustavo-em/react-native-location-confidence/blob/main/docs/COMPARISON.md" rel="noopener noreferrer"&gt;https://github.com/gustavo-em/react-native-location-confidence/blob/main/docs/COMPARISON.md&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you run it on a real phone, I would like to know what the report says in your garage.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;I am Gustavo, a mobile developer in Brazil, open to remote roles.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>reactnative</category>
      <category>opensource</category>
      <category>mobile</category>
      <category>typescript</category>
    </item>
  </channel>
</rss>
