React-native-background-geolocation: it is not working when app terminates (ios), and events is not fired on android.

Created on 16 Jun 2019  路  10Comments  路  Source: mauron85/react-native-background-geolocation

react native

RN: 0.59.8

  • Plugin version: 0.5.3
  • Platform: iOS or Android

Expected Behavior

in android should fire functions
and in ios should send location updates when app terminates

Actual Behavior

function events not fired in android, and location updates not send in ios

stale

Most helpful comment

@mauron85 Yes, I am also getting this issue especially on Android.

I am using the below listener to get location. But mostly I don't get any location and neither it throws any error. But if I check the status it shows as Running. ( BackgroundGeolocation.on('error', (error) => {
console.log('[ERROR] BackgroundGeolocation error:', error);
});
)

BackgroundGeolocation.on('location', (location) => {
}
BackgroundGeolocation.on('stationary', (stationaryLocation) => {
});

All 10 comments

@mauron85 Yes, I am also getting this issue especially on Android.

I am using the below listener to get location. But mostly I don't get any location and neither it throws any error. But if I check the status it shows as Running. ( BackgroundGeolocation.on('error', (error) => {
console.log('[ERROR] BackgroundGeolocation error:', error);
});
)

BackgroundGeolocation.on('location', (location) => {
}
BackgroundGeolocation.on('stationary', (stationaryLocation) => {
});

@hasanal1995 @sujay-bidchat I am also not getting any event on android.
Did you find solution to this?

@Dhanraj-bidchat eventually no,
@mauron85 plz we need help here

@hasanal1995
after upgrading I restarted android powered device and now its working for me.
Restarting device is not a better way though.

sorry, clarify how to fix it plz?
in details @Dhanraj-bidchat

use this method and check if status is running:

  1. BackgroundGeolocation.checkStatus(status => {
    console.log('[INFO] BackgroundGeolocation service is running', status.isRunning);
    console.log('[INFO] BackgroundGeolocation services enabled', status.locationServicesEnabled);
    console.log('[INFO] BackgroundGeolocation auth status: ' + status.authorization);
  // you don't need to check status before start (this is just the example)
  if (!status.isRunning) {
    BackgroundGeolocation.start(); //triggers start on start event
  }
});
  1. if status is running then, you will get output in one of this methods:
    -> BackgroundGeolocation.on('stationary', (stationaryLocation) => {
    // handle stationary locations here
    console.log('[INFO] BackgroundGeolocation service is running', stationaryLocation);
    });

-> BackgroundGeolocation.on('location', (location) => {
// handle your locations here
console.log('[INFO] BackgroundGeolocation service is running', location);
});

ok, i will try and tell you with updates.
thank U very much @Dhanraj-bidchat

still not working bro @Dhanraj-bidchat
on location updates not fires

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

This issue has been automatically closed, because it has not had recent activity. If you believe this issue shouldn't be closed, please reopen or write down a comment requesting issue reopening with explanation why you think it's important. Thank you for your contributions.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dengue8830 picture dengue8830  路  6Comments

HaswinVidanage picture HaswinVidanage  路  3Comments

mikailbayram picture mikailbayram  路  4Comments

Batuhan-Akkaya picture Batuhan-Akkaya  路  4Comments

iocuydi picture iocuydi  路  4Comments