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-bridgefy-sdk-x

v0.0.1

Published

Import Bridgefy React Native modules that can be installed through NPM and easily be used in production.

Downloads

1

Readme

React Native Android Library Bridgefy

Import Bridgefy React Native modules that can be installed through NPM and easily be used in production.

Getting started

  1. Clone the project
  2. Modify/Build the Project in Android Studio
  • Start Android Studio and select File -> New -> Import Project and select the android folder of this package.
  • If you get a Plugin with id 'android-library' not found Error, install android support repository.
  • If you get asked to upgrade gradle to a new version, you can skip it.

Installing it as a library in your main project

There are many ways to do this, here's the way I do it:

1. Push it to Repository.

2. Do npm install --save npm install --save git+ssh://[email protected]/bridgefy/react-native-bridgefy-sdk.git in your main project.

3. Link the library:

  • Add the following to android/settings.gradle:
include ':react-native-bridgefy-sdk'
project(':react-native-bridgefy-sdk').projectDir = new File(settingsDir, '../node_modules/react-native-bridgefy-sdk/android'
  • Add the following to android/app/build.gradle:
 repositories {
             maven {
                 url "http://maven.bridgefy.com/artifactory/libs-release-local"
                 artifactUrls = ["http://jcenter.bintray.com/"]
             }
 }
 dependencies {
                compile project(':react-native-bridgefy-sdk')
}
  • Add the following to android/app/src/main/java/**/MainApplication.java:
  package com.your.package;
  import com.bridgefy.react.sdk.BridgefySdkPackage;  // add this for react-native-bridgefy-sdk
  public class MainApplication extends Application implements ReactApplication {
  @Override
  protected List<ReactPackage> getPackages() {
            return Arrays.<ReactPackage>asList(
                  new MainReactPackage(),
                  new BridgefySdkPackage() // add this for react-native-bridgefy-sdk
            );
          }
  }

4. Simply import/require it by the name defined in your library's index.android.js:

  import Bridgefy from 'react-native-bridgefy-sdk'

  import {
      ...
      DeviceEventEmitter,
    } from 'react-native';

5. Register Bridgefy

  Bridgefy.init("BRIDGEFY_APY_KEY", 
    (errorCode, message)=>{
                console.log(message + ":" + errorCode);
                },
    (client) => {
                console.log(client);
                }
    );

6. Start Bridgefy SDK

BridgefySDK.start();

7. Send messages

  var message = {
                 content:{ // Custom content
                          message:"Hello world!!"
                 },
                 sender_id: client.UserUuid, // Client id of Bridgefy
                 receiver_id:device.UserId,  // Client id of Bridgefy to deliver messages
               };
 // Direct Message
 Bridgefy.sendMessage(message);
 // Broadcast Message
 Bridgefy.sendBroadcastMessage(message);

8. Message and Device listener

//
// BridgefyMessageListener
//
 DeviceEventEmitter.addListener('onMessageReceived', (message)=> {
              console.log('onMessageReceived: '+ JSON.stringify(message));
      }
);
 DeviceEventEmitter.addListener('onMessageSent', (message)=> {
             console.log('onMessageSent: '+ JSON.stringify(message));
      }
 );
 DeviceEventEmitter.addListener('onMessageReceivedException', (error)=> {
               console.log('onMessageReceivedException: '+ error);
               console.log('sender: ' + error.sender); // User ID of the sender
               console.log('code: ' + error.conde); // error code
               console.log('message' + error.message); // message object empty
               console.log('description' + error.description); // Error cause
      }
 );
 DeviceEventEmitter.addListener('onMessageFailed', (error)=> {
              console.log('onMessageFailed: '+ error);
              console.log('code: ' + error.conde); // error code
              console.log('message' + error.message); // message object
              console.log('description' + error.description); // Error cause
     }
 );
 DeviceEventEmitter.addListener('onBroadcastMessageReceived', (message)=> {
             console.log('onBroadcastMessageReceived: '+ JSON.stringify(message));
     }
 );
  //
  // BridgefyStateListener
  //
  DeviceEventEmitter.addListener('onStarted', (device)=> {
             console.log('onStarted: '+ JSON.stringify(device));
  }
 );
  DeviceEventEmitter.addListener('onStartError', (error)=> {
             console.log('onStartError: '+ error);
             console.log('code: ' + error.conde); // error code
             console.log('message' + error.message); // message object empty
             console.log('description' + error.description); // Error cause 
       }
 );
  DeviceEventEmitter.addListener('onStopped', ()=> {
             console.log('onStopped');
       }
 );
  DeviceEventEmitter.addListener('onDeviceConnected', (device)=> {
             console.log('onDeviceConnected: ' + JSON.stringify(device));
      }
 );
  DeviceEventEmitter.addListener('onDeviceLost', (device)=> {
             console.log('onDeviceLost: ' + device);
     }
 );

9. You can test and develop your library by importing the node_modules library into Android Studio if you don't want to install it from git all the time.