diff --git a/README.md b/README.md index 240c03eb..c73a11fe 100644 --- a/README.md +++ b/README.md @@ -182,6 +182,10 @@ class BgTracking extends Component { // But you might be counting on it to receive location updates in the UI, so you could just reconfigure and set `url` to null. }); + BackgroundGeolocation.on('http_authorization', () => { + console.log('[INFO] App needs to authorize the http requests'); + }); + BackgroundGeolocation.checkStatus(status => { console.log('[INFO] BackgroundGeolocation service is running', status.isRunning); console.log('[INFO] BackgroundGeolocation services enabled', status.locationServicesEnabled); @@ -567,6 +571,7 @@ Unregister all event listeners for given event | `foreground` | | Android | all | app entered foreground state (visible) | | `background` | | Android | all | app entered background state | | `abort_requested` | | all | all | server responded with "285 Updates Not Required" | +| `http_authorization`| | all | all | server responded with "401 Unauthorized" | ### Location event | Location parameter | Type | Description | diff --git a/android/lib/src/main/java/com/marianhello/bgloc/react/BackgroundGeolocationModule.java b/android/lib/src/main/java/com/marianhello/bgloc/react/BackgroundGeolocationModule.java index 14a0649f..dd33d840 100644 --- a/android/lib/src/main/java/com/marianhello/bgloc/react/BackgroundGeolocationModule.java +++ b/android/lib/src/main/java/com/marianhello/bgloc/react/BackgroundGeolocationModule.java @@ -40,6 +40,7 @@ public class BackgroundGeolocationModule extends ReactContextBaseJavaModule impl public static final String START_EVENT = "start"; public static final String STOP_EVENT = "stop"; public static final String ABORT_REQUESTED_EVENT = "abort_requested"; + public static final String HTTP_AUTHORIZATION_EVENT = "http_authorization"; public static final String ERROR_EVENT = "error"; private static final int PERMISSIONS_REQUEST_CODE = 1; @@ -412,4 +413,9 @@ public void onError(PluginException error) { public void onAbortRequested() { sendEvent(ABORT_REQUESTED_EVENT, null); } + + @Override + public void onHttpAuthorization() { + sendEvent(HTTP_AUTHORIZATION_EVENT, null); + } } diff --git a/index.js b/index.js index aa0d8d30..a93a2e92 100644 --- a/index.js +++ b/index.js @@ -22,7 +22,8 @@ var BackgroundGeolocation = { 'authorization', 'foreground', 'background', - 'abort_requested' + 'abort_requested', + 'http_authorization' ], DISTANCE_FILTER_PROVIDER: 0,