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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@mylo.ai/react-native-usebutton

v0.2.3

Published

React native module for the Button SDK

Readme

react-native-usebutton

React native module for the Button's publisher SDK

Example app

Installation

$ yarn add @mylo.ai/react-native-usebutton

or

$ npm install --save @mylo.ai/react-native-usebutton

iOS setup

$ cd ios && pod install

Usage

import ButtonSdk from 'react-native-usebutton';

// Before you do anything you have to configure Button with your appID
const applicationId = Platform.select({
  ios: 'app-xxxxxxxxxxxxxxxx',
  android: 'app-xxxxxxxxxxxxxxxx',
});

ButtonSdk.identifyButtonApp(applicationId, error => {
  // If an error has occured, currently only works on iOS
  console.log(error);
});

// Identify a user (on user login)
const userId = 'user-123';
ButtonSdk.setIdentifier(userId);

// Clear all user's data (on user logout)
ButtonSdk.clearAllData();

// Fetch a purchase path from Button
ButtonSDK.startPurchasePath(
  {
    url: 'https://the.button.url',
    token: 'my-tracking-token',
    headerTitle: 'My Button Browser Title',
    headerSubtitle: 'My Button Browser Subtitle',
    headerTitleColor: '#FFFFF',
    headerSubtitleColor: '#FFFFF',
    headerBackgroundColor: '#FFFFF',
    headerTintColor: '#FFFFF',
    footerBackgroundColor: '#FFFFF',
    footerTintColor: '#FFFFF',
  },
  (error) => {
    // If error while fetching the url, you can get it in here!
    console.log(error);
  }
);

// Track impression
ButtonSdk.setImpressionView({
  url: 'https://the.button.url',
  visibleRateType: ButtonSdk.RATE_TYPE.PERCENT,
  creativeType: ButtonSdk.CREATIVE_TYPE.HERO,
  visibleRate: 7,
});

// Event when the browser is closed
ButtonSdk.addEventListener(
  ButtonSdk.EVENT.ON_BROWSER_CLOSED
  onHandlePurchaseClosed
);

// Remove event listener
ButtonSdk.removeEventListener(
  ButtonSdk.EVENT.ON_BROWSER_CLOSED
  onHandlePurchaseClosed
);

Properties for startPurchasePath

| Property | Description | Required | Default | | --------------------------- | ---------------------------------------------------------------------- | -------- | -------------------- | | url | The merchant's url to fetch | true | None | | token | A unique token that can be usefull for tracking a campaign for example | false | None | | headerTitle | The title displayed in the header | true | None | | headerSubtitle | The subitle displayed in the header | true | None | | headerTitleColor | The title's color | false | rgb(255, 255, 255) | | headerSubtitleColor | The subtitle's color | false | rgb(255, 255, 255) | | headerBackgroundColor | The header's background color | false | rgb(0,0,0) | | headerTintColor | The header's tint color | false | rgb(255, 255, 255) | | footerBackgroundColor | The footer's background color | false | rgb(0,0,0) | | footerTintColor | The footer's tint color | false | rgb(255, 255, 255) |

Properties for setImpressionView

| Property | Description | Required | Default | | --------------------- | --------------------------------------------------------------- | -------- | ------------------------ | | url | The merchant's url to track | true | None | | visibleRateType | The rate type : could be percent or fixed | true | None | | creativeType | The creative type | false | CREATIVE_TYPE.HERO | | visibleRate | The rate the user will be granted | true | None |

Visible rate type

| Property | Description | | ----------------------- | ------------------------------- | | RATE_TYPE.PERCENT | The rate type is percentage | | RATE_TYPE.FIXED | The rate type is a fixed amount |

Creative type

| Property | Description | | ---------------------------- | -------------------------- | | CREATIVE_TYPE.HERO | The hero creative type | | CREATIVE_TYPE.CAROUSEL | The carousel creative type | | CREATIVE_TYPE.LIST | The list creative type | | CREATIVE_TYPE.GRID | The grid creative type | | CREATIVE_TYPE.HERO | The hero creative type | | CREATIVE_TYPE.OTHER | The other creative type |

Events

| Property | Description | | ----------------------------- | ------------------------------- | | EVENT.ON_BROWSER_CLOSED | The user has closed the webview |

Typescript

Here a list of the differrent types available:

interface ButtonEvent {
  ON_BROWSER_CLOSED: 'ON_BROWSER_CLOSED';
}

interface RateType {
  FIXED: 'FIXED';
  PERCENT: 'PERCENT';
}

interface CreativeType {
  HERO: 'HERO';
  CAROUSEL: 'CAROUSEL';
  LIST: 'LIST';
  GRID: 'GRID';
  DETAIL: 'DETAIL';
  OTHER: 'OTHER';
}

interface PurchasePathOptions {
  url: string;
  token?: string;
  headerTitle: string;
  headerSubtitle: string;
  headerTitleColor?: string;
  headerSubtitleColor?: string;
  headerBackgroundColor?: string;
  headerTintColor?: string;
  footerBackgroundColor?: string;
  footerTintColor?: string;
}

interface ImpressionViewOptions {
  url: string;
  visibleRateType: IRateType;
  visibleRate: number;
  offerId?: string;
  creativeType?: ICreativeType;
}

type ErrorCallback = (error: string) => void;

Troubleshooting

Android

The Button's SDK can cause your Android app not to be able to connect to the metro server, once installed.

To resolve this, you have to add in the directory android/app/src/main/res/xml of your application, a file named network_security_config.xml and copy/paste this content in it:

<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
  <domain-config cleartextTrafficPermitted="true">
    <domain includeSubdomains="true">localhost</domain>
  </domain-config>
</network-security-config>

Then in your AndroidManifest, add this android:networkSecurityConfig="@xml/network_security_config" inside the application tag.

It has been implemented in the Example app, if you want to see more.

Example app

To run the example app :

$ yarn bootstrap #Install all dependencies (node_modules and pods)
$ cd example && yarn start #Run the metro instance
$ cd .. && yarn example ios/android #Run the application on a simulator

Community

Contribution and development instructions can be found in CONTRIBUTING

License

MIT