项目作者: mloisotto

项目描述 :
React Native Google Smart Lock wrapper for Android
高级语言: Java
项目地址: git://github.com/mloisotto/react-native-smartlock.git
创建时间: 2018-04-23T20:07:36Z
项目社区:https://github.com/mloisotto/react-native-smartlock

开源协议:

下载


react-native-smartlock

A simple wrapper for Smart Lock authentication of Google for React Native. Only for Android.

Installation

$ npm install react-native-smartlock —save

Android" class="reference-link"> Android

android/app/build.gradle

Add the project to your dependencies

  1. dependencies {
  2. ...
  3. compile project(':react-native-smartlock')
  4. }
android/settings.gradle

Add the project

  1. include ':react-native-smartlock'
  2. project(':react-native-smartlock').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-smartlock/android')
MainApplication.java

Add:

  1. import com.google.smartlock.smartlockrn.SmartLockPackager;

  2. In the getPackages() method register the module:
    new SmartLockPackager(MainApplication.this)

So getPackages() should look like:

  1. @Override
  2. protected List<ReactPackage> getPackages() {
  3. return Arrays.<ReactPackage>asList(
  4. new MainReactPackage(),
  5. new SmartLockPackager(MainApplication.this),
  6. //.....
  7. );
  8. }

Usage

  1. import smartLock from 'react-native-smartlock';
  1. smartLock.getCredentials()
  2. .then(credentials => {
  3. console.log(credentials);
  4. // user has permissions
  5. })
  6. .catch(err => {
  7. console.log(err);
  8. // user doesn't have permissions or cancelled login
  9. });