Manos Chorianopoulos

fix startTrackingSteps

......@@ -51,6 +51,29 @@ public class swiftApi {
public func startTrackingSteps(_ getStepsCallback: @escaping (_ steps: Int) -> Void) -> Void {
// Check if there are persistedSteps from previous app kill and save them
let persistedSteps = swiftApi().getSteps()
if (persistedSteps > 0) {
let currentDateTime = Date()
let dateFormatter = DateFormatter()
dateFormatter.dateFormat = "yyyy-MM-dd HH:mm:ss"
let dateString = dateFormatter.string(from: currentDateTime)
swiftApi().setPacingDetailsAsync(persistedSteps, dateString, setPacingDetailsAsyncCallback)
}
func setPacingDetailsAsyncCallback (_ responseData: swiftApi.GenericResponseModel?) -> Void {
if (responseData != nil) {
DispatchQueue.main.async {
if (responseData?.getStatus == 1) {
}
}
} else {
}
}
let instanceOfMyApi = MyApi()
instanceOfMyApi.startTrackingSteps(startTrackingCallback)
......@@ -107,7 +130,7 @@ public class swiftApi {
let queue = DispatchQueue(label: Bundle.main.bundleIdentifier! + ".timer")
timer = DispatchSource.makeTimerSource(queue: queue)
timer!.schedule(deadline: .now(), repeating: .seconds(10))
timer!.schedule(deadline: .now(), repeating: .seconds(60 * 15))
timer!.setEventHandler { [weak self] in
// do whatever stuff you want on the background queue here here
print("========= interval! =========")
......