Utility Methods

Set DeviceToken

The GeoSpark SDK is capable of sending push notifications to your users. Check here to get the device token.

Swift
Objective-C
Swift
func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
GeoSpark.setDeviceToken(deviceToken)
}
Objective-C
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken{
[GeoSpark setDeviceToken:deviceToken];
}

Check Location Permission

Check whether your app has location permission.

Swift
Objective-C
Swift
GeoSpark.isLocationEnabled()
Objective-C
[GeoSpark isLocationEnabled];

Location Permission Status

By using the locationPermissionStatus method you can check the location permission status.

Swift
Objective-C
Swift
GeoSpark.locationPermissionStatus()
Objective-C
[GeoSpark locationPermissionStatus];

notDetermined = 0

restricted = 1

denied = 2

authorizedAlways = 3

authorizedWhenInUse = 4

Request Location Permission

Check whether your App has location permission.

Swift
Objective-C
Swift
GeoSpark.requestLocation()
Objective-C
[GeoSpark requestLocation];

Check Location Tracking

Check whether location tracking is started or not. This method returns a boolean value.

Swift
Objective-C
Swift
GeoSpark.isLocationTracking()
Objective-C
[GeoSpark isLocationTracking];

Current Location

Get the current location of the user. You can set the accuracy between 5 to 100 meters (default is 10).

Swift
Objective-C
Swift
GeoSpark.getCurrentLocation(accuracy) { (location, error) in
//location?.coordinate.latitude
//location?.coordinate.longitude
//location?.altitude
// error?.code
// error?.message
}
Objective-C
[GeoSpark getCurrentLocation:<#(NSInteger)#> handler:^(CLLocation * location, GeoSparkError * error) {
//location?.coordinate.latitude
//location?.coordinate.longitude
//location?.altitude
// error?.code
// error?.message
}];

Update Current Location

Using the updateCurrentLocation method, you can update user current location. You can set the accuracy between 5 to 100 meters (default is 10).

Swift
Objective-C
Swift
GeoSpark.updateCurrentLocation(accuracy)
Objective-C
[GeoSpark updateCurrentLocation: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.

Notification Opened Handler

By using this method inside the Notification delegate method you can track the campaign's impressions and counts.

Swift
Objective-C
Swift
func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void)
{
GeoSpark.notificationOpenedHandler(response)
completionHandler()
}
Objective-C
- (void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void (^)(void))completionHandler{
[GeoSpark notificationOpenedHandler:response];
}

Set Tracking in AppState

Swift
Objective-C
Swift
GeoSpark.setTrackingInAppState(STATE)
Objective-C
[GeoSpark setTrackingInAppState:STATE];

Parameter

Description

STATE

GeoSparkTrackingState.Foreground (or) GeoSparkTrackingState.Background (or)

GeoSparkTrackingState.AlwaysOn

Offline Location Tracking

Swift
Objective-C
Swift
GeoSpark.offlineLocationTracking(Bool)
Objective-C
[GeoSpark offlineLocationTracking];

Parameter

Description

Bool

true (default) -- Offline location enabled. false -- Offline location disabled.

Accuracy Engine

For enabling accuracy engine for Passive, Active, and Balanced tracking

GeoSpark.enableAccuracyEngine()

For disabling accuracy engine

GeoSpark.disableAccuracyEngine()