Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
cordova-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-background-geolocation
Commits
eb1fa765
Commit
eb1fa765
authored
Jun 17, 2015
by
Chris Scott
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
error-handling in getCurrentPosition
parent
a85d5b90
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
57 additions
and
8 deletions
+57
-8
README.md
README.md
+8
-2
CDVBackgroundGeolocation.java
src/android/CDVBackgroundGeolocation.java
+26
-3
transistor-locationmanager.jar
src/android/libs/transistor-locationmanager.jar
+0
-0
CDVBackgroundGeolocation.m
src/ios/CDVBackgroundGeolocation.m
+20
-1
TSLocationManager.h
...nManager.framework/Versions/1/Headers/TSLocationManager.h
+1
-0
CodeDirectory
...amework/Versions/1/Resources/_CodeSignature/CodeDirectory
+0
-0
CodeResources
...amework/Versions/1/Resources/_CodeSignature/CodeResources
+2
-2
CodeSignature
...amework/Versions/1/Resources/_CodeSignature/CodeSignature
+0
-0
TSLocationManager
.../TSLocationManager.framework/Versions/1/TSLocationManager
+0
-0
No files found.
README.md
View file @
eb1fa765
...
@@ -282,8 +282,14 @@ Retrieves the current position. This method instructs the native code to fetch
...
@@ -282,8 +282,14 @@ Retrieves the current position. This method instructs the native code to fetch
######@param {Integer} taskId The taskId used to send to bgGeo.finish(taskId) in order to signal completion of your callbackFn
######@param {Integer} taskId The taskId used to send to bgGeo.finish(taskId) in order to signal completion of your callbackFn
```
```
bgGeo.changePace(true); // <-- Aggressive GPS monitoring immediately engaged.
bgGeo.getCurrentPosition(function(location, taskId) {
bgGeo.changePace(false); // <-- Disable aggressive GPS monitoring. Engages stationary-mode.
// This location is already persisted to plugin’s SQLite db.
// If you’ve configured #autoSync: true, the HTTP POST has already started.
console.log(“- Current position received: “, location);
bgGeo.finish(taskId);
});
```
```
####`changePace(enabled, successFn, failureFn)`
####`changePace(enabled, successFn, failureFn)`
...
...
src/android/CDVBackgroundGeolocation.java
View file @
eb1fa765
...
@@ -31,6 +31,12 @@ public class CDVBackgroundGeolocation extends CordovaPlugin {
...
@@ -31,6 +31,12 @@ public class CDVBackgroundGeolocation extends CordovaPlugin {
private
static
final
String
TAG
=
"TSLocationManager"
;
private
static
final
String
TAG
=
"TSLocationManager"
;
private
static
CordovaWebView
gWebView
;
private
static
CordovaWebView
gWebView
;
public
static
Boolean
forceReload
=
false
;
public
static
Boolean
forceReload
=
false
;
/**
* Timeout in millis for a getCurrentPosition request to give up.
* TODO make configurable.
*/
private
static
final
long
GET_CURRENT_POSITION_TIMEOUT
=
30000
;
public
static
final
String
ACTION_START
=
"start"
;
public
static
final
String
ACTION_START
=
"start"
;
public
static
final
String
ACTION_STOP
=
"stop"
;
public
static
final
String
ACTION_STOP
=
"stop"
;
...
@@ -57,6 +63,7 @@ public class CDVBackgroundGeolocation extends CordovaPlugin {
...
@@ -57,6 +63,7 @@ public class CDVBackgroundGeolocation extends CordovaPlugin {
private
Boolean
stopOnTerminate
=
false
;
private
Boolean
stopOnTerminate
=
false
;
private
Boolean
isMoving
=
false
;
private
Boolean
isMoving
=
false
;
private
Boolean
isAcquiringCurrentPosition
=
false
;
private
Boolean
isAcquiringCurrentPosition
=
false
;
private
long
isAcquiringCurrentPositionSince
;
private
Intent
backgroundServiceIntent
;
private
Intent
backgroundServiceIntent
;
private
DetectedActivity
currentActivity
;
private
DetectedActivity
currentActivity
;
...
@@ -208,13 +215,18 @@ public class CDVBackgroundGeolocation extends CordovaPlugin {
...
@@ -208,13 +215,18 @@ public class CDVBackgroundGeolocation extends CordovaPlugin {
callbackContext
.
success
();
callbackContext
.
success
();
}
else
if
(
BackgroundGeolocationService
.
ACTION_GET_CURRENT_POSITION
.
equalsIgnoreCase
(
action
))
{
}
else
if
(
BackgroundGeolocationService
.
ACTION_GET_CURRENT_POSITION
.
equalsIgnoreCase
(
action
))
{
result
=
true
;
result
=
true
;
onGetCurrentPosition
(
callbackContext
);
if
(!
isEnabled
)
{
callbackContext
.
error
(
401
);
// aka HTTP UNAUTHORIZED
}
else
{
onGetCurrentPosition
(
callbackContext
);
}
}
}
return
result
;
return
result
;
}
}
private
void
onGetCurrentPosition
(
CallbackContext
callbackContext
)
{
private
void
onGetCurrentPosition
(
CallbackContext
callbackContext
)
{
isAcquiringCurrentPosition
=
true
;
isAcquiringCurrentPosition
=
true
;
isAcquiringCurrentPositionSince
=
System
.
nanoTime
();
addCurrentPositionListener
(
callbackContext
);
addCurrentPositionListener
(
callbackContext
);
Bundle
event
=
new
Bundle
();
Bundle
event
=
new
Bundle
();
...
@@ -508,8 +520,18 @@ public class CDVBackgroundGeolocation extends CordovaPlugin {
...
@@ -508,8 +520,18 @@ public class CDVBackgroundGeolocation extends CordovaPlugin {
*/
*/
public
void
onEventMainThread
(
ActivityRecognitionResult
result
)
{
public
void
onEventMainThread
(
ActivityRecognitionResult
result
)
{
currentActivity
=
result
.
getMostProbableActivity
();
currentActivity
=
result
.
getMostProbableActivity
();
String
activityName
=
BackgroundGeolocationService
.
getActivityName
(
currentActivity
.
getType
());
int
confidence
=
currentActivity
.
getConfidence
();
if
(
isAcquiringCurrentPosition
)
{
long
elapsedMillis
=
(
System
.
nanoTime
()
-
isAcquiringCurrentPositionSince
)
/
1000000
;
if
(
elapsedMillis
>
GET_CURRENT_POSITION_TIMEOUT
)
{
isAcquiringCurrentPosition
=
false
;
Log
.
i
(
TAG
,
"- getCurrentPosition timeout, giving up"
);
for
(
CallbackContext
callback
:
currentPositionCallbacks
)
{
callback
.
error
(
408
);
// aka HTTP 408 Request Timeout
}
currentPositionCallbacks
.
clear
();
}
}
}
}
/**
/**
* EventBus listener
* EventBus listener
...
@@ -528,6 +550,7 @@ public class CDVBackgroundGeolocation extends CordovaPlugin {
...
@@ -528,6 +550,7 @@ public class CDVBackgroundGeolocation extends CordovaPlugin {
runInBackground
(
locationCallback
,
result
);
runInBackground
(
locationCallback
,
result
);
if
(
isAcquiringCurrentPosition
)
{
if
(
isAcquiringCurrentPosition
)
{
// Current position has arrived: release the hounds.
isAcquiringCurrentPosition
=
false
;
isAcquiringCurrentPosition
=
false
;
for
(
CallbackContext
callback
:
currentPositionCallbacks
)
{
for
(
CallbackContext
callback
:
currentPositionCallbacks
)
{
result
=
new
PluginResult
(
PluginResult
.
Status
.
OK
,
location
);
result
=
new
PluginResult
(
PluginResult
.
Status
.
OK
,
location
);
...
...
src/android/libs/transistor-locationmanager.jar
View file @
eb1fa765
No preview for this file type
src/ios/CDVBackgroundGeolocation.m
View file @
eb1fa765
...
@@ -20,7 +20,7 @@
...
@@ -20,7 +20,7 @@
[[
NSNotificationCenter
defaultCenter
]
addObserver
:
self
selector
:
@selector
(
onMotionChange
:
)
name
:
@"TSLocationManager.motionchange"
object
:
nil
];
[[
NSNotificationCenter
defaultCenter
]
addObserver
:
self
selector
:
@selector
(
onMotionChange
:
)
name
:
@"TSLocationManager.motionchange"
object
:
nil
];
[[
NSNotificationCenter
defaultCenter
]
addObserver
:
self
selector
:
@selector
(
onEnterGeofence
:
)
name
:
@"TSLocationManager.geofence"
object
:
nil
];
[[
NSNotificationCenter
defaultCenter
]
addObserver
:
self
selector
:
@selector
(
onEnterGeofence
:
)
name
:
@"TSLocationManager.geofence"
object
:
nil
];
[[
NSNotificationCenter
defaultCenter
]
addObserver
:
self
selector
:
@selector
(
onSyncComplete
:
)
name
:
@"TSLocationManager.sync"
object
:
nil
];
[[
NSNotificationCenter
defaultCenter
]
addObserver
:
self
selector
:
@selector
(
onSyncComplete
:
)
name
:
@"TSLocationManager.sync"
object
:
nil
];
[[
NSNotificationCenter
defaultCenter
]
addObserver
:
self
selector
:
@selector
(
onLocationManagerError
:
)
name
:
@"TSLocationManager.error"
object
:
nil
];
}
}
/**
/**
...
@@ -352,6 +352,25 @@
...
@@ -352,6 +352,25 @@
[
bgGeo
error
:
taskId
message
:
error
];
[
bgGeo
error
:
taskId
message
:
error
];
}
}
-
(
void
)
onLocationManagerError
:(
NSNotification
*
)
notification
{
NSLog
(
@" - onLocationManagerError: %@"
,
notification
.
userInfo
);
NSString
*
errorType
=
[
notification
.
userInfo
objectForKey
:
@"type"
];
if
([
errorType
isEqualToString
:
@"location"
])
{
CDVPluginResult
*
result
=
[
CDVPluginResult
resultWithStatus
:
CDVCommandStatus_ERROR
messageAsInt
:[[
notification
.
userInfo
objectForKey
:
@"code"
]
intValue
]];
if
([
self
.
currentPositionListeners
count
])
{
[
result
setKeepCallbackAsBool
:
NO
];
for
(
NSString
*
callbackId
in
self
.
currentPositionListeners
)
{
[
self
.
commandDelegate
sendPluginResult
:
result
callbackId
:
callbackId
];
}
[
self
.
currentPositionListeners
removeAllObjects
];
}
[
self
.
commandDelegate
sendPluginResult
:
result
callbackId
:
locationCallbackId
];
}
}
/**
/**
* If you don't stopMonitoring when application terminates, the app will be awoken still when a
* If you don't stopMonitoring when application terminates, the app will be awoken still when a
* new location arrives, essentially monitoring the user's location even when they've killed the app.
* new location arrives, essentially monitoring the user's location even when they've killed the app.
...
...
src/ios/TSLocationManager.framework/Versions/1/Headers/TSLocationManager.h
View file @
eb1fa765
...
@@ -6,6 +6,7 @@
...
@@ -6,6 +6,7 @@
@property
(
nonatomic
)
CLLocationDistance
odometer
;
@property
(
nonatomic
)
CLLocationDistance
odometer
;
@property
(
nonatomic
,
strong
)
CLLocationManager
*
locationManager
;
@property
(
nonatomic
,
strong
)
CLLocationManager
*
locationManager
;
-
(
void
)
configure
:(
NSDictionary
*
)
config
;
-
(
void
)
configure
:(
NSDictionary
*
)
config
;
-
(
void
)
start
;
-
(
void
)
start
;
-
(
void
)
stop
;
-
(
void
)
stop
;
...
...
src/ios/TSLocationManager.framework/Versions/1/Resources/_CodeSignature/CodeDirectory
View file @
eb1fa765
No preview for this file type
src/ios/TSLocationManager.framework/Versions/1/Resources/_CodeSignature/CodeResources
View file @
eb1fa765
...
@@ -6,7 +6,7 @@
...
@@ -6,7 +6,7 @@
<dict>
<dict>
<key>
Headers/TSLocationManager.h
</key>
<key>
Headers/TSLocationManager.h
</key>
<data>
<data>
JKFHIrez0AKQjHebrRIQXFDiIf
Q=
dTpEJTYyFANcuJNr9upQ8PrgD3
Q=
</data>
</data>
<key>
Info.plist
</key>
<key>
Info.plist
</key>
<data>
<data>
...
@@ -21,7 +21,7 @@
...
@@ -21,7 +21,7 @@
<dict>
<dict>
<key>
Headers/TSLocationManager.h
</key>
<key>
Headers/TSLocationManager.h
</key>
<data>
<data>
JKFHIrez0AKQjHebrRIQXFDiIf
Q=
dTpEJTYyFANcuJNr9upQ8PrgD3
Q=
</data>
</data>
<key>
Modules/module.modulemap
</key>
<key>
Modules/module.modulemap
</key>
<data>
<data>
...
...
src/ios/TSLocationManager.framework/Versions/1/Resources/_CodeSignature/CodeSignature
View file @
eb1fa765
No preview for this file type
src/ios/TSLocationManager.framework/Versions/1/TSLocationManager
View file @
eb1fa765
No preview for this file type
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