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.
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.
To integrate the GeoSpark SDK, you need a GeoSpark account. Our SDK works with iOS 10 and above.
Go to Xcode > File > New Project
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
NSLocationAlwaysAndWhenInUseUsageDescription in the same
<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 >
Follow the steps below to add the SDK to the project using CocoaPods. Add the below to the
This will add the GeoSpark SDK and its dependencies to your project. The GeoSpark SDK depends on
AWSIoT for fetching locations and its transmission to our servers. The SDK supports iOS 10 and above.
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.
Add the following code in
AppDelegate.swift. This code imports the SDK and allows the SDK to use other methods.
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.
Before you start location tracking, you need to get permission from the user for your application to access locations.
CoreLocation at the top of the
Make the below class declaration for Location Manager.
let locationManager = CLLocationManager()
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.
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.
Optimised for/advised for
6% - 12%
25 ~ 250 meters
Ride Hailing / Sharing
3% - 6%
50 ~ 500 meters
On Demand Services
0% - 1%
100 ~ 1000 meters
Use the tracking modes while you use the startTracking method
//cloud integration//active trackingGeoSpark.startTracking(GeoSparkTrackingMode.ACTIVE);// reactive trackingGeoSpark.startTracking(GeoSparkTrackingMode.REACTIVE);// active trackingGeoSpark.startTracking(GeoSparkTrackingMode.ACTIVE);//self-managed integration//active trackingGeoSpark.startSelfTracking(GeoSparkTrackingMode.ACTIVE);// reactive trackingGeoSpark.startSelfTracking(GeoSparkTrackingMode.REACTIVE);// active trackingGeoSpark.startSelfTracking(GeoSparkTrackingMode.ACTIVE);
The SDK also provides a custom tracking mode which allows you to customize and build your own tracking mode as per your requirement.
1m ~ 2500m
Distance between location updates example code:
// define a custom tracking methodlet trackingMethod = GeoSparkTrackingMethods.custom// update the settings for the created method as per needtrackingMethod.activityType = .fitnesstrackingMethod.pausesLocationUpdatesAutomatically = truetrackingMethod.showsBackgroundLocationIndicator = truetrackingMethod.distanceFilter = 10trackingMethod.useSignificantLocationChanges = falsetrackingMethod.useRegionMonitoring = falsetrackingMethod.useVisits = falsetrackingMethod.useSignificantLocationChanges = falsetrackingMethod.desiredAccuracy = .nearestTenMeters
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.