Quickstart

The GeoSpark iOS SDK makes it quick and easy to build a location tracker for your iOS app. We provide powerful and customizable tracking modes and features that can be used to collect your users’ location updates.

Requirements

To use the GeoSpark SDK, the following things are required:

  • Get yourself a free GeoSpark Account. No credit card required.

  • Create a project and add an iOS app to the project.

  • You need the SDK_KEY in your project settings which you’ll need to initialize the SDK.

  • Now you’re ready to integrate the SDK into your iOS application.

The GeoSpark iOS SDK requires Xcode 12 or later and is compatible with apps targeting iOS 10 or above. Swift Package Manager support requires Xcode 12 or later.

Xcode Setup

To integrate the GeoSpark SDK, you need a GeoSpark account. Our SDK works with iOS 10 and above.

  1. Go to Xcode > File > New Project

  2. Configure the information property list file Info.plist with an XML snippet that contains data about your app. You need to add strings for NSLocationWhenInUseUsageDescription in the Info.plist file to prompt the user during location permissions for foreground location tracking. For background location tracking, you also need to add a string for NSLocationAlwaysUsageDescription and NSLocationAlwaysAndWhenInUseUsageDescription in the same Info.plist file.

<key>NSLocationWhenInUseUsageDescription</key>
<string>Add description for foreground only location usage.</string>
<key>NSLocationAlwaysUsageDescription</key>
<string>Add description for background location usage. iOS 10 and below"</string>
<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
<string>Add description for background location usage. iOS 11 and above</string>

3. Next you need to enable Background fetch and Location updates under Project Setting > Capabilities > Background Modes.

Swift Package Installation

Coming Soon…

CocoaPods Installation

Follow the steps below to add the SDK to the project using CocoaPods. Add the below to the Podfile

pod 'GeoSpark'

Then run pod install.

This will add the GeoSpark SDK and its dependencies to your project. The GeoSpark SDK depends on CoreLocation, AWSMobileClient and AWSIoT for fetching locations and its transmission to our servers. The SDK supports iOS 10 and above.

Manual Installation

If you’re not familiar with using Cocoapods or prefer manual installation, we’ve added a ZIP file to the SDK. Use this link to download the GeoSpark.framework.zip file.

Unzip the file and add the GeoSpark SDK GeoSpark.framework to your Xcode project by dragging the file into your Project Navigator.

You can do this by selecting the project file in the navigator on the left side of the Xcode window, and then navigating to the Linked Frameworks and Libraries section. From there, click the “+” button to add the GeoSpark framework.

Initialize SDK

Add the following code in AppDelegate.swift. This code imports the SDK and allows the SDK to use other methods.

import GeoSpark

After import, add the below code under application(_:didFinishLaunchingWithOptions:) in your AppDelegate class. The SDK must be initialized before calling any of the other SDK methods using your project's SDK key.

GeoSpark.intialize("YOUR-SDK-KEY-GOES-HERE")

Request Location Permission

Before you start location tracking, you need to get permission from the user for your application to access locations.

  1. Import CoreLocation at the top of the AppDelegate.swift file.

    import CoreLocation
  2. Make the below class declaration for Location Manager.

    let locationManager = CLLocationManager()
  3. Open AppDelegate.swift and add this line before the return statement in application(_:didFinishLaunchingWithOptions:). With this line, you ask users to allow the app to access location data both in the background and the foreground.

    locationManager.requestAlwaysAuthorization()

Configure Tracking Modes

GeoSpark has three default tracking modes along with a custom version. They are different based on the frequency of location updates and battery consumption. The higher the frequency, the higher the battery consumption.

Mode

Battery usage

Updates every

Optimised for/advised for

Active

6% - 12%

25 ~ 250 meters

Ride Hailing / Sharing

Reactive

3% - 6%

50 ~ 500 meters

On Demand Services

Passive

0% - 1%

100 ~ 1000 meters

Social Apps

Use the tracking modes while you use the startTracking method GeoSpark.startTracking or GeoSpark.startSelfTracking

//cloud integration
//active tracking
GeoSpark.startTracking(GeoSparkTrackingMode.ACTIVE);
// reactive tracking
GeoSpark.startTracking(GeoSparkTrackingMode.REACTIVE);
// active tracking
GeoSpark.startTracking(GeoSparkTrackingMode.ACTIVE);
//self-managed integration
//active tracking
GeoSpark.startSelfTracking(GeoSparkTrackingMode.ACTIVE);
// reactive tracking
GeoSpark.startSelfTracking(GeoSparkTrackingMode.REACTIVE);
// active tracking
GeoSpark.startSelfTracking(GeoSparkTrackingMode.ACTIVE);

Custom Tracking Modes

The SDK also provides a custom tracking mode which allows you to customize and build your own tracking mode as per your requirement.

Type

Unit

Unit Range

Distance Interval

Meters

1m ~ 2500m

Distance between location updates example code:

// define a custom tracking method
let trackingMethod = GeoSparkTrackingMethods.custom
// update the settings for the created method as per need
trackingMethod.activityType = .fitness
trackingMethod.pausesLocationUpdatesAutomatically = true
trackingMethod.showsBackgroundLocationIndicator = true
trackingMethod.distanceFilter = 10
trackingMethod.useSignificantLocationChanges = false
trackingMethod.useRegionMonitoring = false
trackingMethod.useVisits = false
trackingMethod.useSignificantLocationChanges = false
trackingMethod.desiredAccuracy = .nearestTenMeters

Next Steps

  • Cloud Integration Cloud integration is when we manage your data through our servers providing you a system of tools and technologies that connects various applications and systems for the real-time exchange of location data and processes including Insights, Trips, Geofencing and Nearby APIs. ”or”

  • Self-Managed Integration Self-managed integration is when you manage your data by sending all location data back to your server from the SDK directly without communicating to our server. This allows you to keep complete privacy of your data and manage your security standards.