Skip to content

React Native Google Smart Lock wrapper for Android

Notifications You must be signed in to change notification settings

giggsoff/react-native-smartlock

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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/app/build.gradle

Add the project to your dependencies

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

Add the project

include ':react-native-smartlock'
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()

So getPackages() should look like:

@Override
protected List<ReactPackage> getPackages() {
    return Arrays.<ReactPackage>asList(
    new MainReactPackage(),
    new SmartLockPackager(),
    //.....
  );
}

Usage

import smartLock from 'react-native-smartlock';
smartLock.getCredentials()
  .then(credentials => {
      console.log(credentials);
      // user has permissions
  })
  .catch(err => {
      console.log(err);
      // user doesn't have permissions or cancelled login
  });
smartLock.saveCredentials(username, JSON.stringify({'password': password}))
  .then(() => {
       console.warn('saved');
  })
  .catch(err => {
       console.warn(err);
  });

About

React Native Google Smart Lock wrapper for Android

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Java 95.0%
  • JavaScript 5.0%