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
10402f75
Commit
10402f75
authored
Jan 15, 2014
by
Chris Scott
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add setConfig method to allow modification of geolocation params in real-time
parent
e09a4fb8
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
80 additions
and
27 deletions
+80
-27
CDVBackgroundGeoLocation.h
src/ios/CDVBackgroundGeoLocation.h
+1
-0
CDVBackgroundGeoLocation.m
src/ios/CDVBackgroundGeoLocation.m
+59
-27
BackgroundGeoLocation.js
www/BackgroundGeoLocation.js
+20
-0
No files found.
src/ios/CDVBackgroundGeoLocation.h
View file @
10402f75
...
@@ -14,6 +14,7 @@
...
@@ -14,6 +14,7 @@
-
(
void
)
finish
:(
CDVInvokedUrlCommand
*
)
command
;
-
(
void
)
finish
:(
CDVInvokedUrlCommand
*
)
command
;
-
(
void
)
onPaceChange
:(
CDVInvokedUrlCommand
*
)
command
;
-
(
void
)
onPaceChange
:(
CDVInvokedUrlCommand
*
)
command
;
-
(
void
)
setStationaryRadius
:(
CDVInvokedUrlCommand
*
)
command
;
-
(
void
)
setStationaryRadius
:(
CDVInvokedUrlCommand
*
)
command
;
-
(
void
)
setDesiredAccuracy
:(
CDVInvokedUrlCommand
*
)
command
;
-
(
void
)
setDistanceFilter
:(
CDVInvokedUrlCommand
*
)
command
;
-
(
void
)
setDistanceFilter
:(
CDVInvokedUrlCommand
*
)
command
;
-
(
void
)
sync
:(
CLLocation
*
)
location
;
-
(
void
)
sync
:(
CLLocation
*
)
location
;
...
...
src/ios/CDVBackgroundGeoLocation.m
View file @
10402f75
...
@@ -25,8 +25,8 @@
...
@@ -25,8 +25,8 @@
CLCircularRegion
*
myRegion
;
CLCircularRegion
*
myRegion
;
NSInteger
stationaryRadius
;
NSInteger
stationaryRadius
;
NSInteger
distanceFilter
;
NSInteger
distanceFilter
;
NSInteger
locationTimeout
;
NSInteger
desiredAccuracy
;
NSInteger
desiredAccuracy
;
NSInteger
locationTimeout
;
}
}
-
(
void
)
pluginInitialize
-
(
void
)
pluginInitialize
...
@@ -65,22 +65,6 @@
...
@@ -65,22 +65,6 @@
// Set a movement threshold for new events.
// Set a movement threshold for new events.
locationManager
.
activityType
=
CLActivityTypeOther
;
locationManager
.
activityType
=
CLActivityTypeOther
;
locationManager
.
pausesLocationUpdatesAutomatically
=
YES
;
locationManager
.
pausesLocationUpdatesAutomatically
=
YES
;
switch
(
desiredAccuracy
)
{
case
1000
:
locationManager
.
desiredAccuracy
=
kCLLocationAccuracyKilometer
;
break
;
case
100
:
locationManager
.
desiredAccuracy
=
kCLLocationAccuracyHundredMeters
;
break
;
case
10
:
locationManager
.
desiredAccuracy
=
kCLLocationAccuracyNearestTenMeters
;
break
;
case
0
:
locationManager
.
desiredAccuracy
=
kCLLocationAccuracyBest
;
break
;
}
locationManager
.
distanceFilter
=
distanceFilter
;
// meters
locationManager
.
distanceFilter
=
distanceFilter
;
// meters
myRegion
=
nil
;
myRegion
=
nil
;
...
@@ -140,6 +124,11 @@
...
@@ -140,6 +124,11 @@
stationaryRadius
=
[[
command
.
arguments
objectAtIndex
:
0
]
intValue
];
stationaryRadius
=
[[
command
.
arguments
objectAtIndex
:
0
]
intValue
];
NSLog
(
@"- CDVBackgroundGeoLocation setStationaryRadius %d"
,
stationaryRadius
);
NSLog
(
@"- CDVBackgroundGeoLocation setStationaryRadius %d"
,
stationaryRadius
);
UIApplicationState
state
=
[[
UIApplication
sharedApplication
]
applicationState
];
if
(
state
==
UIApplicationStateBackground
)
{
[
self
setPace
:
isMoving
];
}
CDVPluginResult
*
result
=
nil
;
CDVPluginResult
*
result
=
nil
;
result
=
[
CDVPluginResult
resultWithStatus
:
CDVCommandStatus_OK
];
result
=
[
CDVPluginResult
resultWithStatus
:
CDVCommandStatus_OK
];
[
self
.
commandDelegate
sendPluginResult
:
result
callbackId
:
command
.
callbackId
];
[
self
.
commandDelegate
sendPluginResult
:
result
callbackId
:
command
.
callbackId
];
...
@@ -152,11 +141,32 @@
...
@@ -152,11 +141,32 @@
distanceFilter
=
[[
command
.
arguments
objectAtIndex
:
0
]
intValue
];
distanceFilter
=
[[
command
.
arguments
objectAtIndex
:
0
]
intValue
];
NSLog
(
@"- CDVBackgroundGeoLocation setDistanceFilter %d"
,
distanceFilter
);
NSLog
(
@"- CDVBackgroundGeoLocation setDistanceFilter %d"
,
distanceFilter
);
UIApplicationState
state
=
[[
UIApplication
sharedApplication
]
applicationState
];
if
(
state
==
UIApplicationStateBackground
)
{
[
self
setPace
:
isMoving
];
}
CDVPluginResult
*
result
=
nil
;
CDVPluginResult
*
result
=
nil
;
result
=
[
CDVPluginResult
resultWithStatus
:
CDVCommandStatus_OK
];
result
=
[
CDVPluginResult
resultWithStatus
:
CDVCommandStatus_OK
];
[
self
.
commandDelegate
sendPluginResult
:
result
callbackId
:
command
.
callbackId
];
[
self
.
commandDelegate
sendPluginResult
:
result
callbackId
:
command
.
callbackId
];
}
}
/**
* Change stationary radius
*/
-
(
void
)
setDesiredAccuracy
:(
CDVInvokedUrlCommand
*
)
command
{
desiredAccuracy
=
[[
command
.
arguments
objectAtIndex
:
0
]
intValue
];
NSLog
(
@"- CDVBackgroundGeoLocation setDesiredAccuracy %d"
,
desiredAccuracy
);
UIApplicationState
state
=
[[
UIApplication
sharedApplication
]
applicationState
];
if
(
state
==
UIApplicationStateBackground
)
{
[
self
setPace
:
isMoving
];
}
CDVPluginResult
*
result
=
nil
;
result
=
[
CDVPluginResult
resultWithStatus
:
CDVCommandStatus_OK
];
[
self
.
commandDelegate
sendPluginResult
:
result
callbackId
:
command
.
callbackId
];
}
/**
/**
* Called by js to signify the end of a background-geolocation event
* Called by js to signify the end of a background-geolocation event
*/
*/
...
@@ -283,8 +293,30 @@
...
@@ -283,8 +293,30 @@
*/
*/
-
(
void
)
setPace
:(
BOOL
)
value
-
(
void
)
setPace
:(
BOOL
)
value
{
{
NSLog
(
@"- CDVBackgroundGeoLocation setPace %d"
,
value
);
// When stationaryRadius is 0, don't use sig.changes -- keep GPS on constantly.
isMoving
=
value
;
isMoving
=
(
stationaryRadius
==
0
)
?
YES
:
value
;
NSLog
(
@"- CDVBackgroundGeoLocation setPace"
);
NSLog
(
@" isMoving %d"
,
isMoving
);
NSLog
(
@" desiredAccuracy: %d"
,
desiredAccuracy
);
NSLog
(
@" distanceFilter: %d"
,
distanceFilter
);
NSLog
(
@" stationaryRadius: %d"
,
stationaryRadius
);
switch
(
desiredAccuracy
)
{
case
1000
:
locationManager
.
desiredAccuracy
=
kCLLocationAccuracyKilometer
;
break
;
case
100
:
locationManager
.
desiredAccuracy
=
kCLLocationAccuracyHundredMeters
;
break
;
case
10
:
locationManager
.
desiredAccuracy
=
kCLLocationAccuracyNearestTenMeters
;
break
;
case
0
:
locationManager
.
desiredAccuracy
=
kCLLocationAccuracyBest
;
break
;
}
if
(
myRegion
!=
nil
)
{
if
(
myRegion
!=
nil
)
{
[
locationManager
stopMonitoringForRegion
:
myRegion
];
[
locationManager
stopMonitoringForRegion
:
myRegion
];
myRegion
=
nil
;
myRegion
=
nil
;
...
...
www/BackgroundGeoLocation.js
View file @
10402f75
...
@@ -66,6 +66,19 @@ module.exports = {
...
@@ -66,6 +66,19 @@ module.exports = {
'
onPaceChange
'
,
'
onPaceChange
'
,
[
isMoving
]);
[
isMoving
]);
},
},
/**
* @param {Integer} stationaryRadius
* @param {Integer} desiredAccuracy
* @param {Integer} distanceFilter
* @param {Integer} timeout
*/
setConfig
:
function
(
success
,
failure
,
config
)
{
exec
(
success
||
function
()
{},
failure
||
function
()
{},
'
BackgroundGeoLocation
'
,
'
setConfig
'
,
[
config
]);
},
setStationaryRadius
:
function
(
value
,
success
,
failure
)
{
setStationaryRadius
:
function
(
value
,
success
,
failure
)
{
exec
(
success
||
function
()
{},
exec
(
success
||
function
()
{},
failure
||
function
()
{},
failure
||
function
()
{},
...
@@ -73,6 +86,13 @@ module.exports = {
...
@@ -73,6 +86,13 @@ module.exports = {
'
setStationaryRadius
'
,
'
setStationaryRadius
'
,
[
value
]);
[
value
]);
},
},
setDesiredAccuracy
:
function
(
value
,
success
,
failure
)
{
exec
(
success
||
function
()
{},
failure
||
function
()
{},
'
BackgroundGeoLocation
'
,
'
setDesiredAccuracy
'
,
[
value
]);
},
setDistanceFilter
:
function
(
value
,
success
,
failure
)
{
setDistanceFilter
:
function
(
value
,
success
,
failure
)
{
exec
(
success
||
function
()
{},
exec
(
success
||
function
()
{},
failure
||
function
()
{},
failure
||
function
()
{},
...
...
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