Giter Club home page Giter Club logo

Comments (6)

christocracy avatar christocracy commented on August 23, 2024 1

Use $ npx run:android or run:iOS

from react-native-background-geolocation.

christocracy avatar christocracy commented on August 23, 2024

Your app thinks the plug-in is not installed.

go back to the Setup Instructions and install from scratch. Carefully follow all setup instructions.

Also, provide how you’re launching your app.

from react-native-background-geolocation.

Namec999 avatar Namec999 commented on August 23, 2024

i'll restart the process.

it's quite simple also i am runing the regular npx expo start with Expo Go App

from react-native-background-geolocation.

Namec999 avatar Namec999 commented on August 23, 2024

my App.js

`
import React from 'react';
import {
Switch,
Text,
View,
} from 'react-native';

import BackgroundGeolocation, {
Location,
Subscription
} from "react-native-background-geolocation";

const App = () => {
const [enabled, setEnabled] = React.useState(false);
const [location, setLocation] = React.useState('');

React.useEffect(() => {
console.log('[App] useEffect 001');
/// 1. Subscribe to events.
const onLocation = BackgroundGeolocation.onLocation((location) => {
console.log('[onLocation]', location);
setLocation(JSON.stringify(location, null, 2));
})

const onMotionChange = BackgroundGeolocation.onMotionChange((event) => {
  console.log('[onMotionChange]', event);
});

const onActivityChange = BackgroundGeolocation.onActivityChange((event) => {
  console.log('[onActivityChange]', event);
})

const onProviderChange = BackgroundGeolocation.onProviderChange((event) => {
  console.log('[onProviderChange]', event);
})
console.log('[App] useEffect 002');
/// 2. ready the plugin.
BackgroundGeolocation.ready({
  // Geolocation Config
  desiredAccuracy: BackgroundGeolocation.DESIRED_ACCURACY_HIGH,
  distanceFilter: 0,            // Must be 0 or locationUpdateInterval is ignored!
  locationUpdateInterval: 5000,  // Get a location every 5 seconds
  // Activity Recognition
  stopTimeout: 500,
  // Application config
  debug: true, // <-- enable this hear sounds for background-geolocation life-cycle.
  logLevel: BackgroundGeolocation.LOG_LEVEL_VERBOSE,
  stopOnTerminate: false,   // <-- Allow the background-service to continue tracking when user closes the app.
  startOnBoot: true,        // <-- Auto start tracking when device is powered-up.
  // HTTP / SQLite config
  url: 'http://yourserver.com/locations',
  batchSync: false,       // <-- [Default: false] Set true to sync locations to server in a single HTTP request.
  autoSyncThreshold: 5,
  autoSync: true,         // <-- [Default: true] Set true to sync each location to server as it arrives.
  headers: {              // <-- Optional HTTP headers
    "X-FOO": "bar"
  },
  params: {               // <-- Optional HTTP params
    "auth_token": "maybe_your_server_authenticates_via_token_YES?"
  }
}).then((state) => {
  console.log('[App] useEffect 003');
  setEnabled(state.enabled)
  console.log("- BackgroundGeolocation is configured and ready: ", state.enabled);
});

return () => {
  console.log('[App] useEffect Return');
  // Remove BackgroundGeolocation event-subscribers when the View is removed or refreshed
  // during development live-reload.  Without this, event-listeners will accumulate with
  // each refresh during live-reload.
  onLocation.remove();
  onMotionChange.remove();
  onActivityChange.remove();
  onProviderChange.remove();
}

}, []);

/// 3. start / stop BackgroundGeolocation
React.useEffect(() => {
if (enabled) {
BackgroundGeolocation.start();
} else {
BackgroundGeolocation.stop();
setLocation('');
}
}, [enabled]);

return (
<View style={{alignItems:'center'}} className="mt-50">
Click to enable BackgroundGeolocation

<Text style={{fontFamily:'monospace', fontSize:12}}>{location}

)
}

export default App;`

and my package.json

{ "name": "tr02", "version": "1.0.0", "main": "expo/AppEntry.js", "scripts": { "start": "expo start", "android": "expo start --android", "ios": "expo start --ios", "web": "expo start --web" }, "dependencies": { "expo": "~51.0.14", "expo-gradle-ext-vars": "^0.1.2", "expo-status-bar": "~1.12.1", "react": "18.2.0", "react-native": "0.74.2", "react-native-background-fetch": "^4.2.5", "react-native-background-geolocation": "^4.16.3" }, "devDependencies": { "@babel/core": "^7.20.0" }, "private": true }

from react-native-background-geolocation.

Namec999 avatar Namec999 commented on August 23, 2024

do i need to eject my expo app

currently using expo for all our apps because of the dev workflow

from react-native-background-geolocation.

Namec999 avatar Namec999 commented on August 23, 2024

now every thing is OK

it's working only with expo-dev-client not with the regular expo Go app

thanks for your support

you'll hear a lot from me in the next few hours :-) sorry for that lol

from react-native-background-geolocation.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.