npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

rn-calmgeo

v0.9.14

Published

A React Native Module wrapper for CalmGeo

Downloads

10

Readme

rn-calmgeo

npm version MIT licensed npm downloads

A React Native Module wrapper for CalmGeo

Compatibility

| iOS | React Native | | ------ | ------------ | | >=17.0 | >=0.73.9 |

Installation

npm

npm install rn-calmgeo

iOS

cd ios
pod install

API

1. API List

RnCalmGeo

| API | function | | ------------------------------------------------------ | ---------------------------------------------------------------------------- | | start(config: Config): Promise | start service | | config(config: Config): Promise | config & restart service | | stop(): Promise | stop service | | getCount(): Promise | get local record count | | getLocation(): Promise | get current location (also save to local storage) | | clear(): Promise | clear local storage | | sync(): Promise | upload to server | | registerListener(listener: Listener) | regist location listener, return a unsubscriber function object () => void | | isRunning(): Promise | true if the service is running |

2. Types

2.1 Config

| field | type | description | | ---------------------- | -------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ | | desiredAccuracy | DesiredAccuracy | Desired Accuracy | | distanceFilter | number | The minimum distance (measured in meters) a device must move horizontally before an update event is generated. | | disableSpeedMultiplier | boolean | Set true to disable automatic speed-based distanceFilter elasticity. | | speedMultiplier | number | Controls the scale of automatic speed-based distanceFilter elasticity. | | stationaryRadius | number | When stopped, the minimum distance the device must move beyond the stationary location for aggressive background-tracking to engage. | | url? | string | Your server url where you wish to HTTP POST locations to | | token? | string | Bearer token | | httpTimeout | number | HTTP request timeout in milliseconds. | | method | METHOD | The HTTP method. | | autoSync | boolean | If you've enabled HTTP feature by configuring an url, the plugin will attempt to upload each location to your server as it is recorded. | | syncThreshold | number | The minimum number of persisted records to trigger an sync action. | | maxBatchSize | number | If you've enabled HTTP feature by configuring an url and autySync: true, this parameter will limit the number of records attached to each batch. | | maxDaysToPersist | number | Maximum number of days to store a geolocation in local storage. | | fetchActivity | boolean | Set true to fetch activity information. |

2.2 Location

| field | type | description | | --------- | ------------------------ | ----------------------------------------------------------- | | id | string | UUID | | timestamp | string | ISO-8601 UTC timestamp provided by the native location API. | | isMoving | boolean | true if location was recorded while in the moving state. | | coords | COORDS | location info | | activity | Activity | activity info |

2.3 Coords

| field | type | description | | ------------------- | ------- | ------------------------------------------------------------------------------ | | latitude | number | latitude | | longitude | number | longitude | | accuracy | number | accuracy (m) | | altitude | number | altitude | | altitudeAccuracy | number | Accuracy of altitude (m) | | ellipsoidalAltitude | number | ellipsoidalAltitude | | speed | number | speed (m/s) | | speedAccuracy | number | Accuracy of speed (m/s) | | heading | number | heading (north: 0.0) (deg) | | headingAccuracy | number | Accuracy of heading (deg) | | floor | number | floor | | mock | boolean | true if the system generates the location using on-device software simulation. | | external | boolean | true if the system receives the location from an external accessory. |

2.4 Listener

function (location: Location) void

2.5 DesiredAccuracy

  • BEST_FOR_NAVIGATION
  • BEST
  • TEN_METERS
  • HUNDRED_METERS
  • KILOMETER
  • THREE_KILOMETERS

2.5 Method

  • POST
  • PUT

2.6 Activity

| field | type | description | | ---------- | ------ | ------------------------------------------------------------------------------- | | type | enum | still \| on_foot \| walking \| running \| in_vehicle \| on_bicycle \| unknown | | confidence | number | [0~100]% |

Sample

import {
  Config,
  desiredAccuracyEnum,
  requestMethodEnum,
  RnCalmGeo,
  type Location,
} from 'rn-calmgeo';

// config
const configJson: Config = {
  desiredAccuracy: desiredAccuracyEnum.enum.BEST_FOR_NAVIGATION,
  distanceFilter: 16,
  disableSpeedMultiplier: false,
  speedMultiplier: 3.1,
  stationaryRadius: 25.0,

  httpTimeout: 10000,
  method: requestMethodEnum.enum.POST,

  autoSync: true,
  syncThreshold: 12,
  maxBatchSize: 250,
  maxDaysToPersist: 7,
};

// App
export default function App() {
  const [loca, setLoca] = useState<Location | undefined>();

  useEffect(() => {
    RnCalmGeo.start(configJson).then((value: boolean) => {
      console.log('start', value);
    });

    const clean = RnCalmGeo.registerListener(location => {
        setLoca(location);
          console.log('getCount', value);
          setCount(value);
        });
    });

    return clean;
  }, []);

  return (
    <SafeAreaView style={styles.container}>
      <View style={styles.row}>
        <Button title="Stop" onPress={() => RnCalmGeo.stop()} />
        <Button title="Restart" onPress={() => RnCalmGeo.config(configJson)} />
        <Button title="Location" onPress={() => RnCalmGeo.getLocation()} />
      </View>

      <Text>Location: {JSON.stringify(loca, null, 2)}</Text>
    </SafeAreaView>
  );
}

const styles = StyleSheet.create({
  container: {
    marginHorizontal: 20,
    flex: 1,
    alignItems: 'flex-start',
    justifyContent: 'flex-start',
    gap: 10,
  },
  row: {
    alignSelf: 'stretch',
    gap: 10,
    maxHeight: 40,
    flexDirection: 'row',
    alignItems: 'center',
    justifyContent: 'space-between',
  },
  button: {
    backgroundColor: 'blue',
  },
});

Sample Image

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT


Made with create-react-native-library