Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

339
Visualizações
I cant get location services when app is running in background but it works on emulators (React-native)

I can't get location services when my app is running in the background but it works on an emulator. Can anyone help about this problem?

import Geolocation from 'react-native-geolocation-service';
import BackgroundService from 'react-native-background-actions';

const options = {
      taskName: 'Example',
      taskTitle: 'ExampleTask title',
      taskDesc: 'ExampleTask description',
      taskIcon: {
          name: 'ic_launcher',
          type: 'mipmap',
      },
      color: '#ff00ff',
      linkingURI: 'yourSchemeHere://chat/jane',
      parameters: {
          delay:6000,
      },
  };

  const connectSocket = () => {
    const sleep = (time) => new Promise((resolve) => setTimeout(() => resolve(), time));
    const client = new WebSocket(`ws://${ip}:${port}`,'echo-protocol')

    const sendData = (data) => {
      if(client.readyState === client.OPEN){
        client.send(JSON.stringify(data))
      }
    }
  
    const coordianates = async(taskDataArguments) =>{
      const { delay } = taskDataArguments;
        await new Promise( async (resolve) => {
            for (let i = 0; BackgroundService.isRunning(); i++) {

                await BackgroundService.updateNotification({ taskDesc: 'Runned -> ' + i });
                Geolocation.getCurrentPosition(
                  (position) => {

                    sendData(position)

                  },
                  (error) => {
                    console.log(error.code, error.message);
                  },
                  { enableHighAccuracy: true, timeout: 15000, maximumAge: 10000 }
                );
                await sleep(delay);
              }
        });
    }
  
    client.onopen = async(err)=> {
      await BackgroundService.start(coordianates, options);
    }
  } 
about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda