transistorsoft / react-native-background-geolocation

Sophisticated, battery-conscious background-geolocation with motion-detection
http://shop.transistorsoft.com/pages/react-native-background-geolocation
MIT License
2.65k stars 426 forks source link

Start Tracking on Closed Application #2062

Closed souzadeveloper closed 4 months ago

souzadeveloper commented 4 months ago

Your Environment

My HeadlessJS code:

const headlessLocationTask = async (event) => { switch (event.name) { case 'location': console.log('[onLocation HeadlessTask] -', event.name, event.params); await processLocation(event.params); break; } }

BackgroundGeolocation.registerHeadlessTask(headlessLocationTask);


## Expected Behavior
<!--- Tell us what should happen -->

## Actual Behavior
<!--- Tell us what happens instead -->

## Steps to Reproduce
<!--- reproduce this issue; include code to reproduce, if relevant -->
1.
2.
3.
4.

## Context
Hi Chris, today I did a test, I left the application closed and soon after I started moving with my vehicle. The Plugin played the sounds that it was getting the locations but did not register any. If I start the movement with the application open and then close it, then the locations are obtained. Do I need to do anything else besides HeadlessJS?

## Debug logs
<!-- include iOS / Android logs
- ios XCode logs,
- use #getLog #emailLog methods (@see docs)
- Android: $ adb logcat -s TSLocationManager
-->
<details><summary>Logs</summary>

``` <!-- Syntax highlighting:  DO NOT REMOVE -->
PASTE_YOUR_LOGS_HERE

christocracy commented 4 months ago

The Plugin played the sounds that it was getting the locations but did not register any

If the plugin plays the sounds, that means locations were registered, 100% guaranteed.

See Wiki "Debugging" and observe your logs. Search api docs "emailLog".

souzadeveloper commented 4 months ago

Hi Chris, sorry, it was my fault as I put the HeadlessJS Registry in a Context. I switched to my index.js and now my HeadlessJS function is being called correctly.

The logs helped identify this issue.

Thanks

theCoderrrr commented 4 months ago

Merhaba Chris, arkadaşım, HeadlessJS Registry'yi bir Context'e koyduğum için hata verdi. Index.js'imi geçtim ve şimdi HeadlessJS fonksiyonum doğru şekilde çağrılıyor.

Günlükler bu sorunun belirlenmesine yardımcı oldu.

Şerefsizler

Hello, I have the same problem. How did you solve it? Can you help me?

souzadeveloper commented 4 months ago

Merhaba Chris, arkadaşım, HeadlessJS Registry'yi bir Context'e koyduğum için hata verdi. Index.js'imi geçtim ve şimdi HeadlessJS fonksiyonum doğru şekilde çağrılıyor. Günlükler bu sorunun belirlenmesine yardımcı oldu. Şerefsizler

Hello, I have the same problem. How did you solve it? Can you help me?

Hello, explain your problem better or provide some part of your code so I can help you.

theCoderrrr commented 4 months ago

Merhaba Chris, arkadaşım, HeadlessJS Registry'yi bir Context'e koyduğum için hata verdi. Index.js'imi geçtim ve şimdi HeadlessJS fonksiyonum doğru şekilde çağrılıyor. Günlükler bu sorunun belirlenmesine yardımcı oldu. Şerefsizler

Hello, I have the same problem. How did you solve it? Can you help me?

Hello, explain your problem better or provide some part of your code so I can help you.

Should I post it here? If you're using Discord, let's talk there.

souzadeveloper commented 4 months ago

Merhaba Chris, arkadaşım, HeadlessJS Registry'yi bir Context'e koyduğum için hata verdi. Index.js'imi geçtim ve şimdi HeadlessJS fonksiyonum doğru şekilde çağrılıyor. Günlükler bu sorunun belirlenmesine yardımcı oldu. Şerefsizler

Hello, I have the same problem. How did you solve it? Can you help me?

Hello, explain your problem better or provide some part of your code so I can help you.

Should I post it here? If you're using Discord, let's talk there.

I believe this is a good place to continue the subject as it can be useful for other developers and even Chris can help us. Then post it right here.

theCoderrrr commented 4 months ago

Merhaba Chris, arkadaşım, HeadlessJS Registry'yi bir Context'e koyduğum için hata verdi. Index.js'imi geçtim ve şimdi HeadlessJS fonksiyonum doğru şekilde çağrılıyor. Günlükler bu sorunun belirlenmesine yardımcı oldu. Şerefsizler

Hello, I have the same problem. How did you solve it? Can you help me?

Hello, explain your problem better or provide some part of your code so I can help you.

Should I post it here? If you're using Discord, let's talk there.

I believe this is a good place to continue the subject as it can be useful for other developers and even Chris can help us. Then post it right here.

I added headlesstask to my code, but I cannot get updated output. When I want to get debug output, it always gives the old output.

souzadeveloper commented 4 months ago

Merhaba Chris, arkadaşım, HeadlessJS Registry'yi bir Context'e koyduğum için hata verdi. Index.js'imi geçtim ve şimdi HeadlessJS fonksiyonum doğru şekilde çağrılıyor. Günlükler bu sorunun belirlenmesine yardımcı oldu. Şerefsizler

Hello, I have the same problem. How did you solve it? Can you help me?

Hello, explain your problem better or provide some part of your code so I can help you.

Should I post it here? If you're using Discord, let's talk there.

I believe this is a good place to continue the subject as it can be useful for other developers and even Chris can help us. Then post it right here.

I added headlesstask to my code, but I cannot get updated output. When I want to get debug output, it always gives the old output.

BackgroundGeolocation.registerHeadlessTask(headlessLocationTask) must be called necessarily in your index.js. Remove the call from anywhere other than index.js. Without your code I can't help.