Toggle navigation
Toggle navigation
This project
Loading...
Sign in
open-source
/
warply_sdk_framework
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Graphs
Network
Create a new issue
Commits
Issue Boards
Authored by
Manos Chorianopoulos
2023-11-06 14:37:22 +0200
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
9cab2c713dc91804b939c1fea7af2f303d673e55
9cab2c71
1 parent
88584ac3
locationServices enable request fix
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
52 additions
and
39 deletions
SwiftWarplyFramework/SwiftWarplyFramework/TelematicsViewController.swift
SwiftWarplyFramework/SwiftWarplyFramework/TelematicsViewController.swift
View file @
9cab2c7
...
...
@@ -116,32 +116,41 @@ import CoreMotion
// MARK: Actions
@IBAction
private
func
tripButtonTapped
(
_
sender
:
UIButton
)
{
if
(
mIsTripStarted
==
true
)
{
// Stop trip
stopTrip
()
DispatchQueue
.
global
()
.
async
{
if
(
!
self
.
locationServicesIsEnabled
())
{
self
.
onLocationServicesIsDisabled
();
return
;
}
}
else
{
// Start trip
if
let
limitText
=
accelerationLimitTextField
.
text
,
limitText
.
isEmpty
{
// Handle empty limit field
return
DispatchQueue
.
main
.
async
{
if
(
self
.
mIsTripStarted
==
true
)
{
// Stop trip
self
.
stopTrip
()
}
else
{
// Start trip
if
let
limitText
=
self
.
accelerationLimitTextField
.
text
,
limitText
.
isEmpty
{
// Handle empty limit field
return
}
// Disable UI elements
self
.
accelerationLimitTextField
.
isEnabled
=
false
self
.
sampleTimeTextField
.
isEnabled
=
false
// Start location and sensor updates
self
.
requestLocationUpdates
()
// registerSensor()
self
.
mIsTripStarted
=
true
self
.
orientationCountLabel
.
text
=
"0"
self
.
touchCountLabel
.
text
=
"0"
self
.
tripButton
.
setTitle
(
"Stop Trip"
,
for
:
.
normal
)
self
.
mStartTimestamp
=
String
(
Int
(
Date
()
.
timeIntervalSince1970
*
1000
))
// time in milliseconds since January 1, 1970
self
.
initializeOrientation
()
self
.
startTimer
()
}
}
// Disable UI elements
accelerationLimitTextField
.
isEnabled
=
false
sampleTimeTextField
.
isEnabled
=
false
// Start location and sensor updates
requestLocationUpdates
()
// registerSensor()
mIsTripStarted
=
true
orientationCountLabel
.
text
=
"0"
touchCountLabel
.
text
=
"0"
tripButton
.
setTitle
(
"Stop Trip"
,
for
:
.
normal
)
mStartTimestamp
=
String
(
Int
(
Date
()
.
timeIntervalSince1970
*
1000
))
// time in milliseconds since January 1, 1970
initializeOrientation
()
startTimer
()
}
}
...
...
@@ -289,21 +298,25 @@ import CoreMotion
}
private
func
requestLocationUpdates
()
{
if
CLLocationManager
.
locationServicesEnabled
()
{
locationManager
.
desiredAccuracy
=
kCLLocationAccuracyBest
// locationManager.requestLocation()
if
(
!
locationServicesIsEnabled
())
{
onLocationServicesIsDisabled
();
}
else
if
(
authorizationStatusIsDenied
(
status
:
CLLocationManager
.
authorizationStatus
()))
{
onAuthorizationStatusIsDenied
();
}
else
if
(
authorizationStatusNeedRequest
(
status
:
CLLocationManager
.
authorizationStatus
()))
{
onAuthorizationStatusNeedRequest
();
}
else
if
(
authorizationStatusIsGranted
(
status
:
CLLocationManager
.
authorizationStatus
()))
{
onAuthorizationStatusIsGranted
();
DispatchQueue
.
global
()
.
async
{
if
CLLocationManager
.
locationServicesEnabled
()
{
self
.
locationManager
.
desiredAccuracy
=
kCLLocationAccuracyBest
// locationManager.requestLocation()
if
(
!
self
.
locationServicesIsEnabled
())
{
self
.
onLocationServicesIsDisabled
();
}
else
if
(
self
.
authorizationStatusIsDenied
(
status
:
CLLocationManager
.
authorizationStatus
()))
{
self
.
onAuthorizationStatusIsDenied
();
}
else
if
(
self
.
authorizationStatusNeedRequest
(
status
:
CLLocationManager
.
authorizationStatus
()))
{
self
.
onAuthorizationStatusNeedRequest
();
}
else
if
(
self
.
authorizationStatusIsGranted
(
status
:
CLLocationManager
.
authorizationStatus
()))
{
self
.
onAuthorizationStatusIsGranted
();
}
}
else
{
self
.
onLocationServicesIsDisabled
();
}
}
}
...
...
Please
register
or
login
to post a comment