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-mdd-locate-sdk

v1.0.5

Published

React Native wrapper for mdd sdk

Downloads

36

Readme

react-native-mdd-locate-sdk

React Native wrapper for MDD SDK

Installation

npm install react-native-mdd-locate-sdk

Android

You don't need to do anything to deal with library requirements, those will be handled automatically for you.

Permissions

You will need to set up permissions in order to make this work, and which ones you need will be dependent on the react-native versions you are trying to support. Please make sure that you have the following permissions granted in order to use the library propery:

Legacy (<= 30)
  • BLUETOOTH
  • BLUETOOTH_ADMIN
Modern (> 30)
  • BLUETOOTH_SCAN
  • ACCESS_COARSE_LOCATION
  • ACCESS_FINE_LOCATION
  • INTERNET
  • POST_NOTIFICATIONS

iOS

1. Setting Up Required Permissions

To ensure your app functions correctly with the MddLocateSDK:

  1. Open your app's Info.plist.

  2. Add a new entry with the key NSLocationWhenInUseUsageDescription.

  3. Set the value to a string describing why your app needs location access. For instance:

    <key>NSLocationWhenInUseUsageDescription</key>
    <string>We use your location to provide beacon scanning functionality related to vehicles in your vicinity.</string>

2. Enabling Required Capabilities

  1. Open your project settings by clicking on the project name in the Project Navigator.

  2. Select the app target from the list of targets.

  3. Navigate to the "Signing & Capabilities" tab.

  4. Click the + Capability button and add Background Modes.

  5. In the "Background Modes" section, check the boxes for Location updates and Uses Bluetooth LE accessories.

Usage

This SDK provides a React Native interface for the MDD SDK, allowing you to interact with MDD services on both Android and iOS platforms.

Tag Tracking

import { startTrackingTags, stopTrackingTags, addReadHandler } from 'react-native-mdd-locate-sdk';

// Start tracking tags for a user
await startTrackingTags('your-api-key', 'username');

// Add a handler for read events
addReadHandler((event) => {
  console.log('Read event:', event);
});

// Get the current API key
const apiKey = await getApiKey();
console.log('Current API key:', apiKey);

// Stop tracking tags
const stopped = await stopTrackingTags();
console.log('Tracking stopped:', stopped);

Setting this up will allow the SDK to track tags that are available in bluetooth range of the phone and report them automatically to the MDD API.

Tag Detection

import { startDetecting, stopDetecting, addProximityUpdateHandler } from 'react-native-mdd-locate-sdk';

// Start detecting a specific tracking tag
const started = await startDetecting('tracking-tag-id');
console.log('Detection started:', started);

// Add a handler for proximity updates
addProximityUpdateHandler((event) => {
  console.log('Proximity update:', event.proximity);
});

// Stop detecting a specific tracking tag
const stopped = await stopDetecting('tracking-tag-id');
console.log('Detection stopped:', stopped);

This does not actually report to the API, but allows you to find a tag by indicating how close the tag is to a phone. Possible proximity values are: 'unknown', 'near', 'immediate', 'far'.

API Reference

getApiKey(): Promise<string>

Gets the currently configured API key.

  • Returns: A promise that resolves to the current API key

startTrackingTags(apiKey: string, username: string): Promise<void>

Starts tracking tags for the specified username using the provided API key.

  • Parameters:
    • apiKey - Your MDD SDK API key
    • username - The username to associate with tag tracking
  • Returns: A promise that resolves when tracking has started

stopTrackingTags(): Promise<boolean>

Stops tracking tags.

  • Returns: A promise that resolves to true if tracking was successfully stopped

addReadHandler(fn: (event: any) => void): void

Adds a handler for read events.

  • Parameters: fn - A function that will be called with read events

startDetecting(trackingTagId: string): Promise<boolean>

Starts detecting the specified tracking tag.

  • Parameters: trackingTagId - The ID of the tracking tag to detect
  • Returns: A promise that resolves to true if detection was successfully started

stopDetecting(trackingTagId: string): Promise<boolean>

Stops detecting the specified tracking tag.

  • Parameters: trackingTagId - The ID of the tracking tag to stop detecting
  • Returns: A promise that resolves to true if detection was successfully stopped

addProximityUpdateHandler(fn: (event: { proximity: 'unknown' | 'near' | 'immediate' | 'far' }) => void): void

Adds a handler for proximity updates.

  • Parameters: fn - A function that will be called with proximity update events

Error Handling

The SDK includes built-in error handling for common issues such as missing native modules. If you encounter a linking error, ensure that:

  • You have run 'pod install' (for iOS)
  • You have rebuilt the app after installing the package