Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sent an event when the http request is unauthorized #308

Merged
merged 1 commit into from
Oct 21, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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 |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
}
3 changes: 2 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ var BackgroundGeolocation = {
'authorization',
'foreground',
'background',
'abort_requested'
'abort_requested',
'http_authorization'
],

DISTANCE_FILTER_PROVIDER: 0,
Expand Down