Ionic 3 with Background Geolocation

Chen Lit Chian
Apr 16 · 2 min read
Ionic 3 with Background Geolocation

This article will focus on how to create a Background Tracking Mobile Application using Ionic 3 and cordova-plugin-background-geolocation. You can post the gps location to backend service using this app. If you are using ionic 4, please follow this tutorial: Ionic 4 with Background Geolocation.

Step 1

Create a new Ionic 3 project.

npm install -g ionic@3ionic start ionic3-background-geo blank

Step 2

Install plugin and dependencies.

ionic cordova plugin add cordova-plugin-mauron85-background-geolocation@alpha
npm install --save @ionic-native/background-geolocation@4

Install HTTP for http post request to backend service.

ionic cordova plugin add cordova-plugin-advanced-httpnpm install --save @ionic-native/http@4

Optional: You will need to install cordova-android-support-gradle-release if failed to build due to version issue. See here.

cordova plugin cordova-android-support-gradle-release

cordova-android-support-gradle-release is a plugin to align various versions of the Android Support libraries specified by other plugins to a specific version.

Step 3

Add to app.module.ts

import { BackgroundGeolocation } from “@ionic-native/background-geolocation”;
import { HTTP } from "@ionic-native/http";
providers: [BackgroundGeolocation,
HTTP ],

home.ts

Step 4

ionic cordova platform add androidionic cordova prepare android

Step 5

Connect your device and turn on developer mode and enable USB debugging.

ionic cordova run android

Screen Shot

You can find complete source code here.

For more ionic tutorial, please visit www.chenlitchian.com

The End

If you found any problem following the tutorial, please leave your comment below.

If this post was helpful, please click the clap 👏button below a few times to show your support! ⬇⬇

Chen Lit Chian

Written by

Front End Developer at JustLorry

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade