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-broadcast-manager

v0.2.3

Published

Adds custom bridge that enables React Native side to send a broadcast to the native side.

Downloads

6

Readme

react-native-broadcast-manager

A bridge for sending broadcast events from react-native to native code

Author: Applicaster LTD

Platform Support: iOS, tvOS, Android, AndroidTV

Usage (RN Side)

Call sendBroadcastEvent with an event_key (String) and even_properties (type JSON) that later can be caught in the native code and handled upon receiving.

  1. Add the dependency to your package.json file:

    "@applicaster/react-native-broadcast-manager":0.2.3
  2. Send a broadcast message

    import { sendBroadcastEvent } from '@applicaster/react-native-broadcast-manager';
    
    // ...
    
    sendBroadcastEvent("someEventName", {
      "key_1" : "value_1",
      "key_2" : "value_2",
      //...
      "key_n" : "value_n"
    });

Usage (iOS)

Catch the event in your native project by adding the following code:

  private let SomeEventName = Notification.Name("someEventName")

  //..

  //Listen to react native broadcase events,
  //Don't forget to release it on deinit!
  NotificationCenter.default.addObserver(self,
                selector: #selector(didReceiveEvent(_:)),
                name: SomeEventName,
                object: nil)

  //..

  @objc func didReceiveEvent(_ notification:Notification) {
    if let userInfo = notification.userInfo as [String: Any] {
      /*
      The userInfo will contain a dictionary with the JSONObject you sent in the React-Native side.
      */

      //Add more logic here.
    }
  }

Usage (Android)

Catch the event in your native project by adding the following code:

    public static final String EVENT_NAME = "event_name";
    public static final String EVENT_PROPERTIES = "event_properties";
    //..

    public static final String SEND_BROADCAST_ACTION = "send_broadcast_from_rn";

    // Catch the send_broadcast_from_rn action sent from the RN Broadcast Manager
    LocalBroadcastManager.getInstance(context).registerReceiver(new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
                try {
                  //Filter for the intent you sent in the r.n side
                  if ("someEventName".equals(intent.getStringExtra(EVENT_NAME))) {
                    //Get the event properties
                    val event_properties = new JSONObject(intent.getStringExtra(EVENT_PROPERTIES));
                    //Add more logic here
                  }
                } catch (JSONException e) {
                    e.printStackTrace();
                }

        }
    }, new IntentFilter(SEND_BROADCAST_ACTION));

Manifest file setup (for Applicaster plugins only)

If you a working applicaster plugin then add the following configuration to your manifest file.

//For all platforms
"api": {
  //..
  "react_packages": [
    //..
    //Add the following to the bottom of the list.
    "com.applicaster.react.BroadcastManagerAPIPackage"
  ]
}

//...

//Only for iOS/tvOS
"extra_dependencies": [
  {
    "react-native-broadcast-manager": ":path => './node_modules/@applicaster/react-native-broadcast-manager'"
  }
],
//For all platforms
"npm_dependencies": [
  "@applicaster/react-native-broadcast-manager@^0.2.3"
],
//Only for Android/AndroidTV plugins
"project_dependencies": [
  {
    "react-native-broadcast-manager": "./node_modules/@applicaster/react-native-broadcast-manager/Android"
  }
]

License

MIT