-
Notifications
You must be signed in to change notification settings - Fork 0
Utility Methods
Check whether your App has location permission.
GeoSpark.checkLocationPermission( status => {
// do something with status
}); status will be a string, one of:
-
GRANTED
-
DENIED
Android
Check whether the device has location services enabled.
GeoSpark.checkLocationServices( status => {
// do something with status
}); status will be a string, one of:
-
ENABLED
-
DISABLED
Android
Check whether your App has background location permission. Returns a
boolean, which is true if the background location permission has been
granted, and false otherwise.
GeoSpark.checkBackgroundLocationPermission( status => {
// do something with status
});status will be a string, one of:
-
GRANTED
-
DENIED
Call this method to request the user to enable location permissions.
GeoSpark.requestLocationPermission(); Android
Call this method to enable location services.
GeoSpark.requestLocationServices();Android
Call this method to request the user to enable background location permissions.
GeoSpark.requestBackgroundLocationPermission();Check whether location tracking is started or not. This method returns a boolean value.
GeoSpark.isLocationTracking( status => {
// do something with status
});Android
Get the current location of the user. You can set the accuracy from 10 to 100 meters (default is 10).
GeoSpark.getCurrentLocationListener(accuracy);You only need to call these method once, as these settings will be persisted across App sessions.
To listen for location updates, you can add event listeners:
GeoSpark.startListener('location', (result) => {
// do something with location
});You can also remove event listeners:
//Stop location updates
GeoSpark.stopListener('location'); Get the current location of the user in callback.
GeoSpark.getCurrentLocation(DesiredAccuracy, accuracy, success => {
// do something on success
}, error => {
// do something on error
});Parameter |
Description |
|---|---|
DesiredAccuracy |
GeoSpark.DesiredAccuracy.HIGH or GeoSpark.DesiredAccuracy.MEDIUM or |
iOS
GeoSpark.updateCurrentLocationIos(accuracy);Android
Using the updateCurrentLocation method, you can update the user's
current location, you can set the accuracy from 5 to 100 meters (default
is 10).
GeoSpark.updateCurrentLocation(DesiredAccuracy, accuracy);This method should be used only if you need to update the current location of the device with better accuracy. Using this method consistently will consume more battery.
The higher the accuracy the longer the response time time. In some cases it could take up to 30 seconds depending on the GPS signal strength.
Parameter |
Description |
|---|---|
DesiredAccuracy |
GeoSpark.DesiredAccuracy.HIGH or GeoSpark.DesiredAccuracy.MEDIUM or |
iOS
GeoSpark.getCurrentLocationIos(accuracy, success => {
// do something on success
}, error => {
// do something on error
}); Logout from GeoSpark SDK, using logout() method.
NOTE : You need to reinitialize the SDK in case you want to login again.
GeoSpark.logout( success => {
// do something on success
}, error => {
// do something on error
});By using this method inside FirebaseMessagingService class, track the campaign impressions and counts.
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
super.onMessageReceived(remoteMessage);
NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
...
intent.putExtra(GeoSpark.EXTRA, GeoSpark.notificationReceiveHandler(remoteMessage.getData()));
...
notificationManager.notify(NotificationID, builder.build());
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
...
GeoSpark.notificationOpenedHandler(getIntent());
}When running the SDK on Android 6 (and higher), it is recommended to ask the user to disable battery optimization for your application. This ensures that location tracking continues to work when the device is in Doze mode.
Moreover, on Android Pie, disabling battery optimization prevents Adaptive Battery from bucketing your app based on usage and restricting background processing, which can impact the detection quality of the SDK.
After explaining the benefits of disabling battery optimization, call
the disableBatteryOptimization() method of the GeoSpark class.
GeoSpark.disableBatteryOptimization();This will trigger a system dialog asking the user to allow disabling battery optimization for your app.
GeoSpark.isBatteryOptimizationEnabled();GeoSpark SDKs reject Mock Locations on the device by default.
GeoSpark.allowMockLocation(Boolean);Parameter |
Description |
|---|---|
Boolean |
false (default) -- Mock location disabled. |
GeoSpark.setTrackingInAppState(STATE);Parameter |
Description |
|---|---|
STATE |
GeoSpark.AppState.FOREGROUND (or) GeoSpark.AppState.BACKGROUND (or) GeoSpark.AppState.ALWAYS_ON |
GeoSpark.offlineLocationTracking(Boolean);Parameter |
Description |
|---|---|
Boolean |
true (default) -- Offline location enabled. |