Usage
Initialize SSBackgroundGeolocation with your API endpoint and credentials, then start tracking.
Initialize and start tracking
import Sovereigniostracking
SSBackgroundGeolocation.shared.initSDK(
baseUrl: baseUrl,
apiKey: apiKey,
username: username,
clientId: clientId
) { success, accessToken, error in
guard success else {
print("Init failed: \(error ?? "unknown error")")
return
}
SSBackgroundGeolocation.shared.startTracking(
onSuccess: {
print("Tracking started")
},
onError: { errorMessage in
print("Start tracking failed: \(errorMessage)")
}
)
}
Stop tracking
SSBackgroundGeolocation.shared.stopTracking(
onSuccess: { print("Tracking stopped") },
onError: { errorMessage in print(errorMessage) }
)
Query state
SSBackgroundGeolocation.shared.getState(
onResult: { enabled, trackingMode in
print("Tracking enabled: \(enabled)")
},
onError: { errorMessage in print(errorMessage) }
)
Sync offline locations
SSBackgroundGeolocation.shared.sync(
onSuccess: { print("Offline locations synced") },
onError: { errorMessage in print(errorMessage) }
)
Refresh access token
SSBackgroundGeolocation.shared.refreshAccessToken { success, accessToken, error in
// persist the new accessToken
}
Destroy
SSBackgroundGeolocation.shared.destroy(
onSuccess: { print("SDK destroyed") },
onError: { errorMessage in print(errorMessage) }
)
See also: Get Started, Authentication.