christocracy/cordova-plugin-background-geolocation

Android: server side

YairHadari opened this issue · 5 comments

Hi,

From JS I'm calling PHP file that are creating a text file with $_POST['location'] - only for tests.
The problem is that nothing is being passed to $_POST['location'] .
The JS is:
bgGeo.configure(callbackFn, failureFn, {
url: 'http://MyServer.com/WriteBackgroundToDB.php', // <-- only required for Android; ios allows javascript callbacks for your http
params: { // <-- Android ONLY: HTTP POST params sent to your server when persisting locations.
auth_token: 'user_secret_auth_token',
foo: 'bar'
},
headers: { // <-- Android ONLY: Optional HTTP headers sent to your configured #url when persisting locations
'X-Foo': 'BAR'
},
desiredAccuracy: 10,
stationaryRadius: 20,
distanceFilter: 30,
debug: true, // <-- enable this hear sounds for background-geolocation life-cycle.
notificationTitle: 'Background tracking', // <-- android only, customize the title of the notification
notificationText: 'ENABLED' // <-- android only, customize the text of the notification
});

The PHP code is:

Can someone assist please?

it was answered in another issue I believe; instead or reading data from $_POST you need to obtain the data sent to your PHP script by:

$data = file_get_contents('php://input');

simple logging:

file_put_contents("/tmp/tracklog", file_get_contents('php://input'),"\n", FILE_APPEND);

Thanks, problem was solved!!!

Thanks @georgetudor

On Sunday, August 3, 2014, YairHadari notifications@github.com wrote:

Closed #50
#50
.


Reply to this email directly or view it on GitHub
#50 (comment)
.

Snet from Gmail Mobile

Thank you Chris for a great plugin :)

FYI Android has been completely refactored in Premium Version

  • No more in-plugin HTTP -- plugin now executes your Javascript callback, just like iOS
  • Significantly improved battery performance

http://transistorsoft.github.io/cordova-background-geolocation/