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

react-native-yometu-geolocation

v0.1.4

Published

Yometu Geolocation

Downloads

7

Readme

What is react-native-yometu-geolocation

react-native-yometu-geolocation is a library that used to build applications such as fitness, cycling, and other sports that require location updates and timers.

NOTE: Currently only available for iOS

Installation

npm install react-native-yometu-geolocation

// or

yarn add react-native-yometu-geolocation

1. Linking

YFor RN 0.60 or higher, no manual linking is needed. After installing the package, just run pod install from inside ios directory. It'll automatically pickup the package and install it.

2. Info.plist usage descriptions

Finally, you then need to make sure you have the correct usage discriptions inside your Info.plist file. The message will show in the Alert box when your app requests permissions and lets the user know why you are asking for that permissions. They are also part of the App Store review process.

If you are only requesting "when in use" (foreground) location access you just need to make sure you have the NSLocationWhenInUseUsageDescription item in your Plist.

If you are requesting "always" (background) permission you will also need to add NSLocationAlwaysAndWhenInUseUsageDescription and NSLocationAlwaysUsageDescription into your PList file.

The easiest way to add these is to find your Info.plist in Xcode, right click on it, and then choose "edit as source code". You can then enter the items you need into the file:

<key>NSLocationWhenInUseUsageDescription</key>
<string>This is the plist item for NSLocationWhenInUseUsageDescription</string>
<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
<string>This is the plist item for NSLocationAlwaysAndWhenInUseUsageDescription</string>
<key>NSLocationAlwaysUsageDescription</key>
<string>This is the plist item for NSLocationAlwaysUsageDescription</string>

3. Background mode setup (optional)

For background location to work, a few things need to be configured:

  1. In the Xcode project, go to Capabilities, switch on "Background Modes" and check "Location updates". Screenshot

  2. Set NSLocationAlwaysAndWhenInUseUsageDescription and NSLocationAlwaysUsageDescription in your Info.plist file.

Usage

import YometuGeolocation from "react-native-yometu-geolocation";

Get geolocation authorization

This method must be initialized at the beginning (before accessing the location)

YometuGeolocation.requestAuthorization();

Get Realtime Position

In this method you have 2 successful callbacks where one is for realtime location and the other is for getting the timer

// ...

const locationAuthorization = await YometuGeolocation.getPermissionStatus();

if (locationAuthorization.status) {
  watchId = YometuGeolocation.watchLocation(
    {
      accuracy: 'highAccuracy',
      allowBackground: true,
      distanceFilter: 1,
      withTimer: true,
    },
    (loc) => {
      console.log('Watch Current Location ===>', loc);
    },
    (getTimer) => {
      console.log('Watch Timer ====>', getTimer);
    },
    (err: any) => {
      console.log('err watch location ===>', err);
    }
  );
} else {
  // Triger if authorization denied
  console.log(locationAuthorization.message);
}

Stop Realtime Position

// ...

YometuGeolocation.stopWatchLocation(watchId);

Paused Realtime Position

// ...

YometuGeolocation.pauseWatchLocation();

Resume Paused Realtime Position

// ...

YometuGeolocation.resumeWatchLocation();

Get Current Position

This method is used to get the location only occasionally when getting a certain action.

// ...

const locationAuthorization = await YometuGeolocation.getPermissionStatus();

if (locationAuthorization.status) {
  YometuGeolocation.getLocation(
    {
      accuracy: 'highAccuracy',
      cacheAge: 10000,
      distanceFilter: 1,
      timeout: 20000,
    },
    (loc) => {
      console.log('Current Location ===>', loc);
    },
    (err: any) => {
      console.log('err single location ===>', err);
    }
  );
} else {
  console.log(locationAuthorization);
}

Accuracy Options

| Accuracy Value | Description | |-------------------|-----------------------------------------------------------------------------------------------| | bestForNavigation | The highest possible accuracy that uses additional sensor data to facilitate navigation apps. | | nearestTenMeters | Accurate to within ten meters of the desired target. | | hundredMeters | Accurate to within one hundred meters. | | kilometer | Accurate to the nearest kilometer. | | threeKilometers | Accurate to the nearest three kilometers. | | reduced | The level of accuracy used when an app isn’t authorized for full accuracy location data. | | highAccuracy | The best level of accuracy available. |

Troubleshooting

Screenshot

You must enable swift support in your project. Since the iOS implementation is written in swift, you need to add swift support in your project. It can be done just by adding an empty swift file and a bridging header in your project folder. You have to do it from xcode, otherwise swift compiler flag won't be updated.

1. Create empty swift file in your project with XCode

Screenshot

2. Click next button, then save your empty file

Screenshot

3. XCode will ask you "Create Bridging Header".

Screenshot

You can choose "Create Bridging Header", after that rebuild your code, and everything works normally.

This issue is caused by an update to the "Flipper-Folly" pod-spec. If you'd like to keep Flipper enabled, you can override the version in your Podfile:

Open your Podfile in your iOS project and change these lines of codes

# use_flipper! --> Change this to
use_flipper!({ 'Flipper-Folly' => '2.3.0' }) # Update this part
post_install do |installer|
  flipper_post_install(installer)
end

You will need to update your pods by running

pod update

Contributing

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

License

MIT