Add Hypertrack SDK
Add following lines to your applications
We constantly work on making our SDKs better, so make sure you have the latest version of it. You might take a look of its changelog here.
Import Hypertrack SDK
Import the SDK in the main.dart file of your project
Install Hypertrack SDK
Install the SDK using the following command:
Alternatively, the code editor might support flutter pub get. Check the editor docs for your editor to learn more.
Obtain an SDK instance, when you wish to use SDK, by passing your publishable key from the Setup page.
HyperTrack accesses location and activity data, you may use
HyperTrack.requestPermissionsIfNecessary() convenience method to request permissions and make the SDK integration simpler.
Identify your devices
HyperTrack uses string device identifiers that could be obtained from the SDK instance
Make sure you've saved this device identifier as it is required when calling HyperTrack Devices and Trips APIs.
Give your device a name
A device can be tagged with a custom name
Tracking your device
Once you integrated the SDK into your app, you can start tracking your device.
- You can start tracking your device with the API
- You can create trips with destination
- You can also create trips with geofences
Once your app is running, go to the Dashboard where you can see a list of all your devices and their live location with ongoing activity on the map.
You are all set
You can now run the app and start using HyperTrack. You can see your devices on the dashboard.
SDK integration examples
To learn more about SDK integration examples, you may visit these resources:
Frequently Asked Questions
What API levels (Android versions) are supported?
Currently we do support all of the Android versions starting from API 19 (Android 4.4 Kit Kat).
Why do I have NoClassDefFoundError?
I've added SDK and my app started failing with message like:
This takes place because on Android API level 19 and below you cannot have more than 65536 methods in your app (including methods in libraries).
Please check this StackOverflow answer for solutions.
Why do I have persistent notification on my app?
HyperTrack SDK by default runs as a foreground service. This is to ensure that the location tracking works reliably even when your app is minimized.
A foreground service is a service that the user is actively aware of and isn't a candidate for the system to kill when it is low on memory. Android mandates that a foreground service provides a persistent notification in the status bar. This means that the notification cannot be dismissed by the user.
How do I handle custom ROMs?
Smartphones are getting more and more powerful, but the battery capacity is lagging behind. Device manufactures are always trying to squeeze some battery saving features into the firmware with each new Android release. Manufactures like Xiaomi, Huawei and OnePlus have their own battery savers that kills the services running in the background.
To avoid OS killing the service, users of your app need to override the automatic battery management and set it manual.
To inform your users and direct them to the right setting page, you may add the following code in your app. This would intent out your user to the right settings page on the device.
You may also try out open source libraries like AutoStarter.
Some manufacturers don't allow to whitelist apps programmatically.
In that case the only way to achieve service reliability is manual setup. E.g. for Oxygen OS (OnePlus) you need to select Lock menu item from app options button in Recent Apps view:
Why does HyperTrack notification show even after my app is terminated?
The HyperTrack service runs as a separate component and it is still running when the app that started it is terminated. That is why you can observe that notification. When you tracking is stopped, the notification goes away.
How does tracking work in Doze mode?
Doze mode requires device to be stationary, so before OS starts imposing power management restrictions, exact device location is obtained. When device starts moving, Android leaves Doze mode and works regularly, so no special handling of Doze mode required with respect to location tracking.
What is AAPT: error: attribute android:foregroundServiceType not found?
If build fails with error like
AAPT: error: attribute android:foregroundServiceType not found that means that you're targeting your app for Android P or earlier.
Starting from Android 10 Google imposes additional restrictions on services, that access location data while phone screen is turned off. Possible workaround here is to remove declared service property by adding following element to your app's manifest
Although you'll be able to avoid targeting API 29, but tracking service won't work properly on Android Q devices with screen been turned off or locked.