Skip to content

Instantly share code, notes, and snippets.

@devtud
devtud / LoginScreen.tsx
Last active February 12, 2021 11:44
Medium Article: LoginScreen component
import WebView from 'react-native-webview';
import auth from '@react-native-firebase/auth';
const LoginScreen = ({navigation}) => {
return (
<View style={{flex: 1}}>
<WebView
// The server should be accessed from emulator's localhost, otherwise
// you forgot to execute:
//
@devtud
devtud / index.html
Last active February 12, 2021 09:07
Medium Article: Define functions for sending messages to React Native
<script>
...
// We'll inform React Native about errors using this function
function sendErrorMessage(error) {
window.ReactNativeWebView.postMessage(
JSON.stringify({
"type": "error",
"data": undefined,
"error": error
})
@devtud
devtud / index.html
Last active February 12, 2021 09:13
Medium Article: Add event listeners for login buttons
<script>
...
function signIn(providerName) {
// Optional: Send an event from webview to React Native
sendMessage("event", "click-on-login");
if (!firebase.auth().currentUser) {
var provider;
if (providerName === 'google') {
@devtud
devtud / index.html
Last active February 12, 2021 11:32
Initialize Firebase
...
<script>
// Fill this object with your app data. See
// https://firebase.google.com/docs/web/setup#config-object
var firebaseConfig = {
apiKey: '...',
authDomain: '...',
databaseURL: '...',
projectId: '...',
@devtud
devtud / login.html
Last active February 12, 2021 08:26
Firebase Import Scripts
...
<script src="https://www.gstatic.com/firebasejs/8.2.6/firebase-app.js"></script>
<script src="https://www.gstatic.com/firebasejs/8.2.6/firebase-auth.js"></script>
...
<html lang="ro">
<head>
<title>Login</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" type="text/css" href="//fonts.googleapis.com/css?family=Open+Sans"/>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<style type="text/css">
body {
background-color: #fbfbfb;
}
@devtud
devtud / social-auth-with-google.ts
Last active February 12, 2021 11:35
Medium Post: React Native Firebase Auth with Google
// https://rnfirebase.io/auth/social-auth#google
import auth from '@react-native-firebase/auth';
import { GoogleSignin } from '@react-native-community/google-signin';
async function onGoogleButtonPress() {
// Get the users ID token
const { idToken } = await GoogleSignin.signIn();
// Create a Google credential with the token
@devtud
devtud / script.bash
Created November 28, 2018 14:32
```bash xset -display :0.0 dpms force off ```
xset -display :0.0 dpms force off