Google Signin
You can create your own module according to your needs and use it from moduleParams from any method.
Here is a simple example of creating googleSignIn module.
Install
Install and setup react-native-google-signin/google-signin package from here. After that, create a file named google-signin.js and paste below code.
google-signin.js
import { GoogleSignin, statusCodes, GoogleSigninButton } from '@react-native-google-signin/google-signin';
export default {
GoogleSignin, statusCodes, GoogleSigninButton
}
And include the googleSignIn in RNNano componenent like below
import {RNNano} from 'react-native-nano';
import googleSignIn from 'google-signin';
const customModules = {
"googleSignIn": googleSignIn,
}
const App = () => {
return <RNNano screens={[]} customModules={customModules} />;
};
export default App;
And use the googleSignIn module from any method like below.
const buttonPress = {
component: NANO.BUTTON,
value: 'SIGN IN',
onPress: ({ moduleParams }) => {
const googleSignIn = moduleParams['googleSignIn'];
googleSignIn["GoogleSignin"].hasPlayServices()
.then(() => {
googleSignIn["GoogleSignin"].signIn()
.then((userInfo) => {}).catch((error) => {});
})
.catch((error) => {
if (error.code === googleSignIn["statusCodes"].SIGN_IN_CANCELLED) {
console.log("SIGN_IN_CANCELLED")
} else if (error.code === googleSignIn["statusCodes"].IN_PROGRESS) {
console.log("IN_PROGRESS")
} else if (error.code === googleSignIn["statusCodes"].PLAY_SERVICES_NOT_AVAILABLE) {
console.log("PLAY_SERVICES_NOT_AVAILABLE")
} else {
console.log("UNKNOWN")
}
console.log(error)
});
}
};
const screen = {
name: 'HomeScreen',
screen: {
h1: [buttonPress],
}
};