title: Ionic 2 / Ionic 3 : How to get current location of a device
body: <p>None of the answers on <strong>stackoverflow</strong>  worked for me. A lot of them are for <strong>Ionic 1</strong> or those answers are deprecated or they are not working for android device.</p>
  
  <p>I have seen a lot of solutions on <strong>stackoverflow</strong> about getting current location of device but non of them seems to be working for Android .</p>
  
  <p><strong>what i have tried:-</strong></p>
  
  <ul>
  <li><p>using <code>geolocation.getCurrentPosition()</code> , which is working for <strong>IOS</strong> and <strong>browser</strong> but not for <strong>Android</strong>.</p></li>
  <li><p>using <code>this.geolocation.watchPosition()</code>  , which is working for <strong>IOS</strong> and <strong>browser</strong> but not for <strong>Android</strong>.</p></li>
  <li><p>using <code>navigator.geolocation.getCurrentPosition()</code>,which is working for <strong>IOS</strong> and <strong>browser</strong> but not for <strong>Android</strong>.</p></li>
  <li><p>using fiddle solution provided by this question <a href="https://stackoverflow.com/questions/32106849/getcurrentposition-and-watchposition-are-deprecated-on-insecure-origins">getCurrentPosition() and watchPosition() are deprecated on insecure origins</a></p></li>
  </ul>
  
  <p>Anyway , all of these are <strong>deprecated</strong> by google due to :-</p>
  
  <blockquote>
    <p>getCurrentPosition() and watchPosition() are deprecated on insecure
    origins, and support will be removed in the future. You should
    consider switching your application to a secure origin, such as HTTPS.
    See goo.gl/rStTGz for more details.</p>
  </blockquote>
  
  <ul>
  <li><strong>what worked for me is (<a href="https://ionicframework.com/docs/native/background-geolocation/" rel="nofollow noreferrer">https://ionicframework.com/docs/native/background-geolocation/</a> ) &amp; (<a href="https://www.joshmorony.com/adding-background-geolocation-to-an-ionic-2-application/" rel="nofollow noreferrer">https://www.joshmorony.com/adding-background-geolocation-to-an-ionic-2-application/</a> ) both  of these are based on <code>background-geolocation plugin</code> but,it's  taking almost 50-55 sec on Android device, again it's working fine for ios</strong> </li>
  </ul>
  
  <p>The problem with <strong>joshmorony</strong>(<a href="https://www.joshmorony.com/adding-background-geolocation-to-an-ionic-2-application/" rel="nofollow noreferrer">https://www.joshmorony.com/adding-background-geolocation-to-an-ionic-2-application/</a> ) solution is foreground is not working for Android physical devices but working fine for browser and ios. Background tracking is working fine , which is taking almost 50 sec to give lat &amp; lng for the first time.</p>
  
  <p>Please help me with this. I want a way to get current location in minimum time. For your info, I am using google <strong>javascript</strong> map sdk / api .</p>