Skip to content

Instantly share code, notes, and snippets.

View adhithiravi's full-sized avatar
🎯
Focusing

Adhithi Ravichandran adhithiravi

🎯
Focusing
View GitHub Profile
import * as Keychain from 'react-native-keychain';
import DeviceInfo from 'react-native-device-info'
async () => {
const username = 'adhithi';
const password = 'poniesRgr8';
const server = DeviceInfo.getBundleId()
// Store the credentials
await Keychain.setInternetCredentials(server, email, password).then(() => {
Keychain.getInternetCredentials(server).then(credentials => {
if (credentials) {
console.log('Credentials successfully loaded for user ' + credentials.username)
}
else {
console.log('Could not retrieve credentials for server')
}
}).catch(error => {
console.log('Could not get credentials from keychain')
})
// using react-native-device-info to get server information
const server = DeviceInfo.getBundleId()
Keychain.setInternetCredentials(server, email, password).then(() => {
console.log('Saved internet credentials')
}).catch(error => {
console.log('Could not save credentials')
})
Keychain.getSupportedBiometryType().then(biometryType => {
this.setState({ biometryType });
});
import * as Keychain from 'react-native-keychain';
async () => {
const username = 'zuck';
const password = 'poniesRgr8';
// Store the credentials
await Keychain.setGenericPassword(username, password);
try {
@adhithiravi
adhithiravi / FingerPrintComp.js
Last active September 19, 2018 04:35
Example showing authentication using touch id
'use strict';
import React, { Component } from 'react';
import {
AlertIOS,
StyleSheet,
Text,
TouchableHighlight,
View,
} from 'react-native';
@adhithiravi
adhithiravi / TouchID.js
Last active September 19, 2018 04:28
Show an example usage of isSupported()
clickHandler() {
TouchID.isSupported()
.then(biometryType => {
// Success code
if (biometryType === 'FaceID') {
console.log('FaceID is supported.');
} else if (biometryType === 'TouchID'){
console.log('TouchID is supported.');
} else if (biometryType === true) {
// Touch ID is supported on Android
import React, { Component } from 'react';
import {
AlertIOS,
StyleSheet,
Text,
TouchableHighlight,
View,
NativeModules
} from 'react-native';
/**
* Sample React Native App
* https://github.com/facebook/react-native
*
* @format
* @flow
*/
import React, {Component} from 'react';
import {Platform, StyleSheet, Text, View} from 'react-native';
@adhithiravi
adhithiravi / VideoComponent.js
Created August 16, 2018 19:34
VideoComponent.js
import React, {Component} from 'react'
import PropTypes from 'prop-types'
import { View, StyleSheet } from 'react-native'
import Video from 'react-native-video'
export default class VideoComponent extends React.Component {
renderVideo () {
return(
<Video