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

No task registered for key BackgroundGeolocation #320

Open
Saliheen opened this issue Jun 11, 2024 · 0 comments
Open

No task registered for key BackgroundGeolocation #320

Saliheen opened this issue Jun 11, 2024 · 0 comments

Comments

@Saliheen
Copy link

Saliheen commented Jun 11, 2024

I am getting No task registered for key BackgroundGeolocation for background location tracking.

Source Code

import {StyleSheet, Text, View} from 'react-native';
import React, {useEffect} from 'react';
import Radar from 'react-native-radar';


const App = () => {
  const doSetup = async () => {
    Radar.initialize('prj_test__________________');
    Radar.setUserId('1234567');
    Radar.setLogLevel("info");
  };

  const handlePermisions = async () => {
    // request foreground location permissions
    Radar.requestPermissions(false)
      .then(status => {
        // request background location permissions
        Radar.requestPermissions(true)
          .then(status => {
            // do something with status
          })
          .catch(err => {
            // optionally, do something with err
          });
      })
      .catch(err => {
        // optionally, do something with err
      });
  };


  const trackUserLocationInFoprground = async ()=> {
    Radar.trackOnce().then((result) => {  
      // console.log({result})
    }).catch((err) => { 
        console.log(err)
     });
  }

  const trackLocationInBackground = async () => {
    Radar.startTrackingContinuous();
  }


  const registerListeners = () => {
    Radar.on('clientLocation', (result:any) => {
      console.log(JSON.stringify({ event: 'clientLocation', result }, null, 2));
    });
    Radar.on('location', (result:any) => {
      console.log(JSON.stringify({ event: 'location', result }, null, 2));
    });
    Radar.on('events', (result:any) => {
      console.log(JSON.stringify({ event: 'events', result }, null, 2));
    });
    Radar.on('error', (err:any) => {
      console.error(JSON.stringify({ event: 'error', err }, null, 2));
    });
  };
  

  useEffect(() => {
    doSetup();
    handlePermisions();
    trackUserLocationInFoprground()
    trackLocationInBackground()
  }, []);

  return (
    <View style={styles.container}>
      <Text>Test Radar SDK</Text>
    </View>
  );
};

export default App;

const styles = StyleSheet.create({
  container: {
    display: 'flex',
    flex: 1,
    alignItems: 'center',
    justifyContent: 'center',
  },
});


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant