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
797c1a78
Commit
797c1a78
authored
Sep 15, 2014
by
Mark Pearce
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updated OBJ-C and Java to have new option parameter 'stopOnTerminate'
parent
5e1376a4
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
157 additions
and
116 deletions
+157
-116
README.md
README.md
+16
-11
BackgroundGpsPlugin.java
src/android/BackgroundGpsPlugin.java
+21
-6
LocationUpdateService.java
src/android/LocationUpdateService.java
+48
-47
CDVBackgroundGeoLocation.h
src/ios/CDVBackgroundGeoLocation.h
+1
-0
CDVBackgroundGeoLocation.m
src/ios/CDVBackgroundGeoLocation.m
+65
-47
BackgroundGeoLocation.js
www/BackgroundGeoLocation.js
+6
-5
No files found.
README.md
View file @
797c1a78
...
...
@@ -83,7 +83,8 @@ A full example could be:
notificationTitle: 'Background tracking', // <-- android only, customize the title of the notification
notificationText: 'ENABLED', // <-- android only, customize the text of the notification
activityType: 'AutomotiveNavigation',
debug: true // <-- enable this hear sounds for background-geolocation life-cycle.
debug: true, // <-- enable this hear sounds for background-geolocation life-cycle.
stopOnTerminate: false // <-- enable this to clear background location settings when the app terminates
});
// Turn ON the background-geolocation system. The user will be tracked whenever they suspend the app.
...
...
@@ -181,6 +182,10 @@ Compare now background-geolocation in the scope of a city. In this image, the l

#####`@param {Boolean} stopOnTerminate`
Enable this in order to force a stop() when the application terminated (e.g. on iOS, double-tap home button, swipe away the app)
### Android Config
#####`@param {String} url`
...
...
src/android/BackgroundGpsPlugin.java
View file @
797c1a78
...
...
@@ -33,6 +33,7 @@ public class BackgroundGpsPlugin extends CordovaPlugin {
private
String
isDebugging
=
"false"
;
private
String
notificationTitle
=
"Background tracking"
;
private
String
notificationText
=
"ENABLED"
;
private
String
stopOnTerminate
=
"false"
;
public
boolean
execute
(
String
action
,
JSONArray
data
,
CallbackContext
callbackContext
)
{
Activity
activity
=
this
.
cordova
.
getActivity
();
...
...
@@ -56,6 +57,7 @@ public class BackgroundGpsPlugin extends CordovaPlugin {
updateServiceIntent
.
putExtra
(
"isDebugging"
,
isDebugging
);
updateServiceIntent
.
putExtra
(
"notificationTitle"
,
notificationTitle
);
updateServiceIntent
.
putExtra
(
"notificationText"
,
notificationText
);
updateServiceIntent
.
putExtra
(
"stopOnTerminate"
,
stopOnTerminate
);
activity
.
startService
(
updateServiceIntent
);
isEnabled
=
true
;
...
...
@@ -69,8 +71,8 @@ public class BackgroundGpsPlugin extends CordovaPlugin {
result
=
true
;
try
{
// Params.
// 0 1 2 3 4 5 6 7 8 8 9
//[params, headers, url, stationaryRadius, distanceFilter, locationTimeout, desiredAccuracy, debug, notificationTitle, notificationText, activityType]
// 0 1 2 3 4 5 6 7 8 8 9
10
//[params, headers, url, stationaryRadius, distanceFilter, locationTimeout, desiredAccuracy, debug, notificationTitle, notificationText, activityType
, stopOnTerminate
]
this
.
params
=
data
.
getString
(
0
);
this
.
headers
=
data
.
getString
(
1
);
this
.
url
=
data
.
getString
(
2
);
...
...
@@ -81,6 +83,7 @@ public class BackgroundGpsPlugin extends CordovaPlugin {
this
.
isDebugging
=
data
.
getString
(
7
);
this
.
notificationTitle
=
data
.
getString
(
8
);
this
.
notificationText
=
data
.
getString
(
9
);
this
.
stopOnTerminate
=
data
.
getString
(
10
);
}
catch
(
JSONException
e
)
{
callbackContext
.
error
(
"authToken/url required as parameters: "
+
e
.
getMessage
());
}
...
...
@@ -92,4 +95,16 @@ public class BackgroundGpsPlugin extends CordovaPlugin {
return
result
;
}
/**
* Override method in CordovaPlugin.
* Checks to see if it should turn off
*/
public
void
onDestroy
()
{
Activity
activity
=
this
.
cordova
.
getActivity
();
if
(
isEnabled
&&
stopOnTerminate
.
equalsIgnoreCase
(
"true"
))
{
activity
.
stopService
(
updateServiceIntent
);
}
}
}
src/android/LocationUpdateService.java
View file @
797c1a78
...
...
@@ -94,6 +94,7 @@ public class LocationUpdateService extends Service implements LocationListener {
private
Boolean
isDebugging
;
private
String
notificationTitle
=
"Background checking"
;
private
String
notificationText
=
"ENABLED"
;
private
Boolean
stopOnTerminate
;
private
ToneGenerator
toneGenerator
;
...
...
src/ios/CDVBackgroundGeoLocation.h
View file @
797c1a78
...
...
@@ -23,6 +23,7 @@
-
(
void
)
getStationaryLocation
:(
CDVInvokedUrlCommand
*
)
command
;
-
(
void
)
onSuspend
:(
NSNotification
*
)
notification
;
-
(
void
)
onResume
:(
NSNotification
*
)
notification
;
-
(
void
)
onAppTerminiate
:(
NSNotification
*
)
notification
;
@end
src/ios/CDVBackgroundGeoLocation.m
View file @
797c1a78
...
...
@@ -21,6 +21,7 @@
BOOL
isDebugging
;
BOOL
enabled
;
BOOL
isUpdatingLocation
;
BOOL
stopOnTerminate
;
NSString
*
token
;
NSString
*
url
;
...
...
@@ -77,6 +78,7 @@
stationaryLocation
=
nil
;
stationaryRegion
=
nil
;
isDebugging
=
NO
;
stopOnTerminate
=
NO
;
maxStationaryLocationAttempts
=
4
;
maxSpeedAcquistionAttempts
=
3
;
...
...
@@ -112,6 +114,7 @@
desiredAccuracy
=
[
self
decodeDesiredAccuracy
:[[
command
.
arguments
objectAtIndex
:
6
]
intValue
]];
isDebugging
=
[[
command
.
arguments
objectAtIndex
:
7
]
boolValue
];
activityType
=
[
self
decodeActivityType
:[
command
.
arguments
objectAtIndex
:
9
]];
stopOnTerminate
=
[[
command
.
arguments
objectAtIndex
:
10
]
boolValue
];
self
.
syncCallbackId
=
command
.
callbackId
;
...
...
@@ -129,6 +132,7 @@
NSLog
(
@" - desiredAccuracy: %ld"
,
(
long
)
desiredAccuracy
);
NSLog
(
@" - activityType: %@"
,
[
command
.
arguments
objectAtIndex
:
7
]);
NSLog
(
@" - debug: %d"
,
isDebugging
);
NSLog
(
@" - stopOnTerminate: %d"
,
stopOnTerminate
);
}
-
(
void
)
addStationaryRegionListener
:(
CDVInvokedUrlCommand
*
)
command
...
...
@@ -393,6 +397,20 @@
}
}
/**@
* Termination. Checks to see if it should turn off
*/
-
(
void
)
onAppTerminiate
:(
NSNotification
*
)
notification
{
NSLog
(
@"- CDVBackgroundGeoLocation terminate"
);
if
(
isUpdatingLocation
&&
stopOnTerminate
)
{
[
self
stopUpdatingLocation
];
}
}
-
(
void
)
locationManager
:(
CLLocationManager
*
)
manager
didUpdateLocations
:(
NSArray
*
)
locations
{
NSLog
(
@"- CDVBackgroundGeoLocation didUpdateLocations (isMoving: %d)"
,
isMoving
);
...
...
www/BackgroundGeoLocation.js
View file @
797c1a78
...
...
@@ -22,12 +22,13 @@ module.exports = {
notificationTitle
=
config
.
notificationTitle
||
"
Background tracking
"
,
notificationText
=
config
.
notificationText
||
"
ENABLED
"
;
activityType
=
config
.
activityType
||
"
OTHER
"
;
stopOnTerminate
=
config
.
stopOnTerminate
||
false
;
exec
(
success
||
function
()
{},
failure
||
function
()
{},
'
BackgroundGeoLocation
'
,
'
configure
'
,
[
params
,
headers
,
url
,
stationaryRadius
,
distanceFilter
,
locationTimeout
,
desiredAccuracy
,
debug
,
notificationTitle
,
notificationText
,
activityType
]
[
params
,
headers
,
url
,
stationaryRadius
,
distanceFilter
,
locationTimeout
,
desiredAccuracy
,
debug
,
notificationTitle
,
notificationText
,
activityType
,
stopOnTerminate
]
);
},
start
:
function
(
success
,
failure
,
config
)
{
...
...
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