Getting Started
These are the list of steps to get started with the app suite for your use-case and optionally turn on push notifications.
- Setting up Firebase Project
- Register a Google account if you don’t have one. Log in to your browser with your Google account.
- Go to Firebase console and follow this tutorial until 1:20 (don’t create iOS app).
- You probably need to associate some payment method to your project, don’t expect too much billing though: I have more than a dozen of projects and got bills of 5 cents per month. Although I don’t manage a large fleet of vehicles but only a pair of cars by DIY GPS Tracker.
- Register DIY GPS Tracker app with your Firebase project, you’ll need to use
dev.csaba.diygpstracker
as a package name. - Add SHA1 certificate fingerprint of 4A:1C:EE:06:88:08:3F:9E:3B:59:E9:D0:B4:E2:F5:FD:E6:D3:8A:91
- Add SHA256 certificate fingerprint of 3D:4D:CA:B0:31:BA:8B:D1:C6:0D:E5:D2:37:21:A0:81:C1:94:DD:C0:95:85:31:18:17:2C:89:D8:13:39:8F:ED
- Register DIY GPS Manager app with your Firebase project, you’ll need to use
dev.csaba.diygpsmanager
as a package name. - Add SHA1 certificate fingerprint of CF:C5:F4:A3:C0:DD:46:3F:00:A6:BE:2E:63:7B:74:28:19:96:98:F4
- Add SHA256 certificate fingerprint of 3D:94:4C:4E:23:0E:9D:AF:B8:C0:2A:F9:17:CF:83:11:B2:05:85:C6:87:59:39:4A:9A:18:FD:52:71:A4:FA:CD
- Under the Authentication section of the Firebase project enable Sign-In methods you’d like to use with the app suite. For reference how to enable Google SIgn-In take a look at the very beginning of this video Currently Anonymous, Google and Email+Password methods are supported.
- Under the Database section activate Firestore feature of your Firebase project. This is not the Realtime Database, it must be Firestore. See this video from 2:10
- Make sure to secure down your Firestore based on which authentication method you use with the database Rules. The data structure is the following: you’ll have a collection of “Assets” as you add new assets with the manager. As soon as any asset will have it’s DIYGPSTracker running and will start reporting the location, each asset will have its own Reports collection and eventually if any GeoFence is violated then a Notifications collection.
- Install DIYGPSManager on an Android device you’ll use for managing assets and supervising them
- Install DIYGPSManager from the app store (or if you compile your own then side load it).
- In your Firebase project select the DIYGPSManager associated app and remember the App ID and the Web API Keys.
- Under the settings of the application specify the Project ID, App ID and Web API Keys you saw.
- You only need to specify Email and Password if you picked Email+Password preferred authentication method otherwise it should be left blank. In case of Email+Password authentication you must not reuse passwords for any other accounts for security reasons. The app uses Jetpack Security to encrypt any preferences (for the reason for these preferences see my motivation how the app is used). If the phone is used in interactive setups you can use Google authentication which is more secure, but may require Sign-In if the app stops by any chance.
- The app will navigate to the Asset List view, where you can add an entry for each asset you’d like to track.
- You can manually override the reporting time interval, geo fence lock radius, manually lock/unlock the asset or navigate to a map view to see the asset’s current location and it’s trajectory in the near past.
- When you lock the asset the Tracker app would report back the current location and establish a geofence around that location with the given radius. Once the asset leaves that area the status icon will change from green checkmark to red, the Tracker will switch to a 10 seconds reporting interval and you may also receive a push notification.
- Install DIYGPSTracker on the asset devices
- Install DIYGPSTracker from the app store (or if you compile your own then side load it).
- Disable battery optimization for the DIYGPSTracker app and make sure it’ll stay in the foreground to avoid any limitations of the Android system. Even if battery optimization is disabled phone manufacturer’s own schemes may kill of worker processes if the app is in the background, see this reference (“Phone makers are breaking your favorite apps with reckless changes to Android’s power optimization features”) and this reference (“Don’t Kill My App benchmark”).
- In your Firebase project select the DIYGPSTracker associated app and remember the App ID and the Web API Keys.
- Under the settings of the application specify the Project ID, App ID and Web API Keys you saw.
- You only need to specify Email and Password if you picked Email+Password preferred authentication method otherwise it should be left blank. In case of Email+Password authentication you must not reuse passwords for any other accounts for security reasons. The app uses Jetpack Security to encrypt any preferences (for the reason for these preferences see my motivation how the app is used). If the phone is used in interactive setups you can use Google authentication which is more secure, but may require Sign-In if the app stops by any chance.
- The app should list the assets you created with the DIYGPSManager. Pick the asset which will be tracked by the device you are handling right now.
- After picking an asset the Tracker will display the latest location, battery level it reported to your Firestore. Stay on that view and lock the device.
- Enable push notifications (optional, under progress)
- Activate Cloud Functions in your Firebase project.
- Clone the https://github.com/DIYGPSTracker/DIYGPSMessaging repository.
- Build and deploy the messaging cloud functions with the following steps:
npm install -g firebase-tools
firebase login
firebase init functions
. Only select Cloud Functions if you are offered any other features of Firestore (Database, Hosting, …). Select JavaScript as a language. Don’t overwrite the current function.npm install
firebase deploy --only functions