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

bridgefy-react-native

v1.1.6

Published

Bridgefy React Native SDK

Downloads

21

Readme

Bridgefy React Native SDK

GitHub last commit GitHub issues

The Bridgefy Software Development Kit (SDK) is a state-of-the-art, plug-and-play package that will let people use your mobile app when they don’t have access to the Internet, by using Bluetooth mesh networks.

Integrate the Bridgefy SDK into your Android and iOS app to reach the 3.5 billion people that don’t always have access to an Internet connection, and watch engagement and revenue grow!

Website. https://bridgefy.me/sdk Email. [email protected] witter. https://twitter.com/bridgefy Facebook. https://www.facebook.com/bridgefy

Operation mode

All the connections are handled seamlessly by the SDK to create a mesh network. The size of this network depends on the number of devices connected and the environment as a variable factor, allowing you to join nodes in the same network or nodes in different networks.

networking

Platform permissions

To utilize this SDK in a React Native application, you'll need to configure permissions for each individual platform (iOS and Android) first. You can read more about each platform's requirements below:

Installation

$ npm i bridgefy-react-native
# --- or ---
$ yarn install bridgefy-react-native

Usage

Initialization

The initialize method initializes the Bridgefy SDK with the given API key and propagation profile. We will configure event listeners later.

import { Bridgefy, BridgefyPropagationProfile } from 'bridgefy-react-native';

const bridgefy = new Bridgefy();

export default function App() {
    React.useEffect(() => {
        bridgefy
            .initialize({
                apiKey: 'your-api-key-here', // UUID - The license key registered on the Bridgefy developer site.
                verboseLogging: false, // The logging priority for SDK operations.
            })
            .catch((error) => {
                console.error(error);
            });
    });
}

Once initialized, you can call start and stop Bridgefy SDK operations as follows:

/**
 * Start Bridgefy SDK operations
 */
bridgefy.start(
  userId, // UUID? (optional) - The ID used to identify the user in the Bridgefy network.If null is passed, the SDK will assign an autogenerated ID.
  propagationProfile, // PropagationProfile (optional, default: PropagationProfile.Standard) - A profile that defines a series of properties and rules for the propagation of messages.
);

/**
 * Stop Bridgefy SDK operations
 */
bridgefy.stop()

Sending data

The following method is used to send data using a transmission mode. This method returns a UUID to identify the message that was sent. You'll need to serialize your data into a string before transmission so React Native can communicate the information to the native platform.

async function sendData() {
  const userId = await bridgefy.currentUserId();
  const lastMessageId = await bridgefy.send(
    'data', // String encoded data to send.
    {
      type: BridgefyTransmissionModeType.broadcast,
      uuid: userId,
    },
  );
}

Responding to SDK events

The SDK can report events to your app through an instance of React's NativeEventEmitter.

The following is an example subscription to a couple of events. Each message will contain information relevant to the event being transmitted.

React.useEffect(() => {
  const subscriptions: EmitterSubscription[] = [];
  const eventEmitter = new NativeEventEmitter(
    NativeModules.BridgefyReactNative
  );
  // When the Bridgefy SDK started successfully.
  subscriptions.push(
    eventEmitter.addListener(BridgefyEvents.bridgefyDidStart, (event) => {
      console.log(`Bridgefy started`, event);
    })
  );
  // When this device received data from another Bridgefy device.
  subscriptions.push(
    eventEmitter.addListener(
      BridgefyEvents.bridgefyDidReceiveData,
      (event) => {
        console.log(`Bridgefy received data`, event);
      }
    )
  );
  return () => {
    for (const sub of subscriptions) {
      sub.remove();
    }
  };
});

To see a full list of events, see the BridgefyEvents enum.

Additional Functionality

The Bridgefy class also provides various functionalities:

  • destroySession(): Destroy current session.
  • updateLicense(): Update license.
  • establishSecureConnection(userId: string): Promise<void>: Establish a secure connection with a specified user.
  • currentUserId(): Promise<string>: Get the current user ID.
  • connectedPeers(): Promise<string[]>: Get a list of connected peers.
  • licenseExpirationDate(): Promise<Date>: Get the license expiration date.
  • isInitialized(): Promise<boolean>: Check if the SDK is initialized.
  • isStarted(): Promise<boolean>: Check if the SDK is started.

Make sure to handle promises and error scenarios appropriately when using these methods.

Bridgefy Propagation Profiles

The BridgefyPropagationProfile enum defines the following propagation profiles available for use:

  • standard: Standard propagation profile.
  • highDensityNetwork: High-density network profile.
  • sparseNetwork: Sparse network profile.
  • longReach: Long-reach profile.
  • shortReach: Short-reach profile.

These profiles can be used when configuring the Bridgefy SDK operations within your React Native application.

Multi-Platform Support

Bridgefy's SDKs are designed to work seamlessly across different platforms, including iOS and Android. This means that users with different devices can communicate with each other as long as they have the Bridgefy-enabled applications installed.

Contact & Support

© 2023 Bridgefy Inc. All rights reserved