Testing

Our Mobile SDKs make it easy not just to build but to test location features in your apps as well. This doc covers various such APIs available in the SDKs and talks about how they can be used for testing purposes.

SDK Debug Logging

HyperTrack SDKs have console logging DISABLED by default for all Log Levels except for ERROR and WARNING.

To enable VERBOSE SDK logging, call HyperTrack.enableDebugLogging(int) API with Log.VERBOSE as parameter.

// Specify Log level as parameter to enable logs upto that level
HyperTrack.enableDebugLogging(Log.VERBOSE);
// This API is not available for iOS SDK (Swift) yet.
// We're working on adding this API and will update soon.
// This API is not available for iOS SDK (Obj-C) yet.
// We're working on adding this API and will update soon.

Using Mock Location Apps

HyperTrack SDKs rejects Mock Locations on the device by default. In essence, mock location apps provide a continuous stream of locations (latlongs) and the SDK generates location data accompanied with activity & device health data. This makes mock location apps insufficient for testing the full power of HyperTrack features. Read more about it in depth in our blog on Detecting mock locations on Android.

We recommend using HyperTrack Mock APIs for your testing but if you want to test using Mock location apps, call HyperTrack.enableMockLocations(boolean) API to enable mock locations on the sdk.

// Call this API to enable mock locations in the sdk. 
// With this the SDK will start accepting all mock locations.
HyperTrack.enableMockLocations(true);
// This API is not required for iOS.
// This API is not required for iOS.

Mocking User's tracking session

A user’s tracking session starts with HyperTrack.startTracking() and ends with HyperTrack.stopTracking(). In order to mock user movement developers would call HyperTrack.startMockTracking(callback) and HyperTrack.stopMockTracking() respectively.

[info] How it works?

HyperTrack.startMockTracking() API starts a simulation from the device's current location to a nearby place of interest within a 5-10km radius so the session is long enough to test your app & its features.

// Replace startTracking API with startMockTracking
// HyperTrack.startTracking();
HyperTrack.startMockTracking(new HyperTrackCallback() {
    @Override
    public void onSuccess(@NonNull SuccessResponse response) {
        // Handle startMockTracking success here
    }

    @Override
    public void onError(@NonNull ErrorResponse errorResponse) {
        // Handle startMockTracking error here
        Toast.makeText(MainActivity.this, errorResponse.getErrorMessage(), Toast.LENGTH_SHORT).show();
    }
});

// Replace stopTracking API with stopMockTracking
// HyperTrack.stopTracking();
HyperTrack.stopMockTracking();
// Replace startTracking API with startMockTracking
// HyperTrack.startTracking
HyperTrack.startMockTracking

// Replace stopTracking API with stopMockTracking
// HyperTrack.stopTracking;
HyperTrack.stopMockTracking
// Replace startTracking API with startMockTracking
// [HyperTrack startTracking];
[HyperTrack startMockTracking];

// Replace stopTracking API with stopMockTracking
// [HyperTrack stopTracking];
[HyperTrack stopMockTracking];

There are similar methods available to start the simulation from specified source location to specified destination location. Refer to Android MockTracking reference for more info.

[warning] Call stopMockTracking

Once the simulation is over or your testing is done, remember to call HyperTrack.stopMockTracking() API to stop user's mocked session.

Mock Tracking to a Particular Destination

You can mock a tracking session to end to a destination of your choice.By default, the session will start from your current location but you can also give an origin.

These methods are only available in SDK version > 0.4.55 compatible with Xcode 9/swift 4.

// Create a mock location params object with the coordinate of destination and start mock tracking
let locationParams = HTMockLocationParams.init(destination: CLLocationCoordinate2D.init(latitude: 28.4712236, longitude: 77.1026893))
HyperTrack.startMockTracking(params:locationParams)


// Replace stopTracking API with stopMockTracking
// HyperTrack.stopTracking
HyperTrack.stopMockTracking

These methods are only available in SDK version > 0.4.55 compatible with Xcode 9/swift 4.

// Replace startTracking API with startMockTracking
// [HyperTrack startTracking];
HTMockLocationParams * locationParams = [[HTMockLocationParams alloc]initWithDestination:CLLocationCoordinate2DMake(28.4712236, 77.1026893)];
[HyperTrack startMockTrackingWithParams:locationParams];


// Replace stopTracking API with stopMockTracking
// [HyperTrack stopTracking];
[HyperTrack stopMockTracking];
LatLng startLatLng = new LatLng(28.578231,77.2417049);
LatLng destinationLatLng = new LatLng(28.4712236,77.1026893);
HyperTrack.startMockTracking(startLatLng,destinationLatLng,new HyperTrackCallback() {
    @Override
     public void onSuccess(@NonNull SuccessResponse successResponse) {
        // Handle Success Here
     }

    @Override
     public void onError(@NonNull ErrorResponse errorResponse) {
         // Handle  Error here

     }
 });

results matching ""

    No results matching ""