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

@enhancers/react-native-background-geofence

v0.1.3

Published

background geofence

Downloads

266

Readme

react-native-background-geofence

background geofence

Installation

npm install @enhancers/react-native-background-geofence

Configuration

Android

Add this to your AndroidManifest.xml file:

<service
android:name="com.enhancers.backgroundgeofence.services.BoundaryEventJobIntentService"
android:enabled="true"
android:exported="true"
android:permission="android.permission.BIND_JOB_SERVICE" />
<service android:name="com.enhancers.backgroundgeofence.services.BoundaryEventHeadlessTaskService" />
<receiver
android:name="com.enhancers.backgroundgeofence.receivers.BoundaryEventBroadcastReceiver"
android:enabled="true" />

IOS

Add this keys to app info.plist file

<key>NSLocationWhenInUseUsageDescription</key>
<string>Background Geofencing</string>
<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
<string>Background Geofencing</string>

Usage

BackgroundGeofence.addGeofence

BackgroundGeofence.addGeofence is a method used to add a geofence with specific parameters such as latitude, longitude, radius, and notifications for entering and exiting the geofence.

Usage

BackgroundGeofence.addGeofence({
    id: TEST_GEOFENCE_ID,
    lat: 34.017714,
    lng: -118.499033,
    radius: 50, // in meters
    enterGeofenceNotificationTitle: 'enter-titolo',
    enterGeofenceNotificationText: 'enter-testo',
    exitGeofenceNotificationTitle: 'exit-titolo',
    exitGeofenceNotificationText: 'exit-testo',
    })
    .then((id: string) =>
        console.log('[geofence] Added geofence with id', id)
    )
    .catch((e: any) =>
        console.error('[geofence] Error in BackgroundGeofence.addGeofence', e)
    );
});

Parameters

  • id (string): Unique identifier for the geofence.
  • lat (number): Latitude of the geofence center.
  • lng (number): Longitude of the geofence center.
  • radius (number): Radius of the geofence in meters.
  • enterGeofenceNotificationTitle (string): Title for the notification displayed when entering the geofence.
  • enterGeofenceNotificationText (string): Text for the notification displayed when entering the geofence.
  • exitGeofenceNotificationTitle (string): Title for the notification displayed when exiting the geofence.
  • exitGeofenceNotificationText (string): Text for the notification displayed when exiting the geofence.

Geofence Event Listeners

The following code demonstrates how to set up listeners for ENTER and EXIT geofence events using the BackgroundGeofence.on method. These listeners allow you to execute specific actions when a device enters or exits a geofenced area.

Usage

const onEnterEvent = BackgroundGeofence.on(
  GeofenceEvent.ENTER,
  (id: string) => {
    console.log(`Enter event ${id}!!`);
    setLastEventReceived(GeofenceEvent.ENTER + ' - ' + id);
  }
);

const onExitEvent = BackgroundGeofence.on(
  GeofenceEvent.EXIT,
  (id: string) => {
    console.log(`Exit event ${id}!!`);
    setLastEventReceived(GeofenceEvent.EXIT + ' - ' + id);
  }
);

Parameters BackgroundGeofence.on(eventType, callback)

  • eventType (string): Type of geofence event to listen for. It can be one of the following:
    • GeofenceEvent.ENTER: Triggered when the device enters a geofenced area.
    • GeofenceEvent.EXIT: Triggered when the device exits a geofenced area.
  • callback (function): The function to be executed when the specified event occurs. The callback receives the following parameter:
    • id (string): The ID of the geofence that triggered the event.