Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
cordova-plugin-background-geolocation
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Aksimaya
cordova-plugin-background-geolocation
Commits
d2cfb3b4
Commit
d2cfb3b4
authored
Feb 11, 2014
by
Chris Scott
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement locationManager failure-handler for handling airplane-mode, no GPS
parent
cdedf302
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
6 deletions
+24
-6
CDVBackgroundGeoLocation.m
src/ios/CDVBackgroundGeoLocation.m
+24
-6
No files found.
src/ios/CDVBackgroundGeoLocation.m
View file @
d2cfb3b4
...
...
@@ -235,7 +235,10 @@
-
(
void
)
locationManager
:(
CLLocationManager
*
)
manager
didUpdateLocations
:(
NSArray
*
)
locations
{
NSLog
(
@"- CDVBackgroundGeoLocation didUpdateLocations (isMoving: %hhd)"
,
isMoving
);
if
(
!
isMoving
&&
!
isAcquiringStationaryLocation
&&
!
stationaryLocation
)
{
// Perhaps our GPS signal was interupted, re-acquire a stationaryLocation now.
[
self
setPace
:
NO
];
}
CLLocation
*
newLocation
=
[
locations
lastObject
];
// Handle location updates as normal, code omitted for brevity.
...
...
@@ -267,9 +270,6 @@
if
(
isDebugging
)
{
AudioServicesPlaySystemSound
(
acquiredLocationSound
);
}
[
locationManager
stopUpdatingLocation
];
isAcquiringStationaryLocation
=
NO
;
[
locationManager
startMonitoringSignificantLocationChanges
];
[
self
startMonitoringStationaryRegion
:
stationaryLocation
];
}
...
...
@@ -306,6 +306,17 @@
}
}
}
-
(
void
)
locationManager
:(
CLLocationManager
*
)
manager
didFailWithError
:(
NSError
*
)
error
{
NSLog
(
@"- CDVBackgroundGeoLocation locationManager failed: %@"
,
error
);
[
locationManager
stopUpdatingLocation
];
isMoving
=
NO
;
isAcquiringStationaryLocation
=
NO
;
stationaryLocation
=
nil
;
[
locationManager
startMonitoringSignificantLocationChanges
];
}
-
(
BOOL
)
isBestStationaryLocation
:(
CLLocation
*
)
location
{
stationaryLocationAttempts
++
;
if
(
stationaryLocationAttempts
==
4
)
{
...
...
@@ -391,7 +402,6 @@
{
NSLog
(
@"- CDVBackgroundGeoLocation paused location updates"
);
[
self
setPace
:
NO
];
[
self
startMonitoringStationaryRegion
:[
locationManager
location
]];
}
/**
* 1. Turn off significantChanges ApI
...
...
@@ -413,7 +423,7 @@
if
(
isDebugging
)
{
AudioServicesPlaySystemSound
(
isMoving
?
paceChangeYesSound
:
paceChangeNoSound
);
}
if
(
value
==
YES
)
{
if
(
isMoving
)
{
if
(
stationaryRegion
!=
nil
)
{
[
locationManager
stopMonitoringForRegion
:
stationaryRegion
];
stationaryRegion
=
nil
;
...
...
@@ -439,9 +449,17 @@
CLLocationCoordinate2D
coord
=
[
location
coordinate
];
NSLog
(
@"- CDVBackgroundGeoLocation createStationaryRegion (%f,%f)"
,
coord
.
latitude
,
coord
.
longitude
);
if
(
stationaryRegion
!=
nil
)
{
[
locationManager
stopMonitoringForRegion
:
stationaryRegion
];
}
isAcquiringStationaryLocation
=
NO
;
[
locationManager
stopUpdatingLocation
];
locationManager
.
distanceFilter
=
distanceFilter
;
locationManager
.
desiredAccuracy
=
desiredAccuracy
;
[
locationManager
startMonitoringSignificantLocationChanges
];
stationaryRegion
=
[[
CLCircularRegion
alloc
]
initWithCenter
:
coord
radius
:
stationaryRadius
identifier
:
@"BackgroundGeoLocation stationary region"
];
stationaryRegion
.
notifyOnExit
=
YES
;
[
locationManager
startMonitoringForRegion
:
stationaryRegion
];
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment