Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@icehunter/react-native-play-licensing

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@icehunter/react-native-play-licensing

Adds [Client-Side License Verification](https://developer.android.com/google/play/licensing/client-side-verification) to React Native applications. Works on both Android and iOS, but only verifies licenses on Android.

latest
Source
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

React Native Play Licensing

Adds Client-Side License Verification to React Native applications. Works on both Android and iOS, but only verifies licenses on Android.

Installing

npm install react-native-play-licensing

Linking Native Dependencies

Automatic Linking

react-native link react-native-play-licensing

Manual Linking

  • In android/settings.gradle

    ...
    include ':react-native-play-licensing'
    project(':react-native-play-licensing').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-play-licensing/android')
    
  • In android/app/build.gradle

    ...
    dependencies {
        ...
        implementation project(':react-native-play-licensing')
    }
    
  • Register module in MainApplication.java

    import com.github.icehunter.playlicensing.PlayLicensingPackage;  // <--- import
    public class MainApplication extends Application implements ReactApplication {
      ......
      @Override
      protected List<ReactPackage> getPackages() {
          return Arrays.<ReactPackage>asList(
              new MainReactPackage(),
              ......
              new PlayLicensingPackage(),  // <--- add package
          );
      }
      ......
    }
    

Usage

To use the react-native-play-licensing package in your codebase, use the PlayLicensing module:

import PlayLicensing from 'react-native-play-licensing';
export default function (App) {
  // ...
  const [licensed, setLicensed] = useState(null);
  useEffect(() => {
    PlayLicensing.verify('MIIBIjANBgkqhkiG...').then(setLicensed);
  }, []);
  // do something if app is not licensed
  // ...
}

API

  • verify(BASE64_PUBLIC_KEY, STRING_FOR_SALT)
PlayLicensing.verify(BASE64_PUBLIC_KEY).then((licensed) => {
  if (licensed === true) {
    // app was purchased from Google Play
  } else if (licensed === false) {
    // app was not purchased from Google Play
  } else {
    // verification failed, retry later
  }
});

FAQs

Package last updated on 17 Mar 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts