Add onVideoChunkReady
This commit is contained in:
@@ -1,17 +1,26 @@
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import { Alert, Button, View, Text, TextInput, TouchableWithoutFeedback, Keyboard } from "react-native";
|
||||
import auth, { FirebaseAuthTypes } from '@react-native-firebase/auth';
|
||||
import React, { useState, useEffect } from "react";
|
||||
import {
|
||||
Alert,
|
||||
Button,
|
||||
View,
|
||||
Text,
|
||||
TextInput,
|
||||
TouchableWithoutFeedback,
|
||||
Keyboard,
|
||||
} from "react-native";
|
||||
import auth, { FirebaseAuthTypes } from "@react-native-firebase/auth";
|
||||
|
||||
// This code is beginning of Auth Implementation - actual implementation will differ and involve more UI
|
||||
// Does not have a restart or proper handling of code confirmation, should only be used for obtaining token/testing
|
||||
// Currently working for Android builds, iOS has open issue #56
|
||||
|
||||
|
||||
export default function Login() {
|
||||
const [phoneNumber, setPhoneNumber] = useState<string>('');
|
||||
const [code, setCode] = useState<string>('');
|
||||
const [phoneNumber, setPhoneNumber] = useState<string>("");
|
||||
const [code, setCode] = useState<string>("");
|
||||
|
||||
const [user, setUser] = useState(null);
|
||||
const [confirm, setConfirm] = useState<FirebaseAuthTypes.ConfirmationResult | null>(null);
|
||||
const [confirm, setConfirm] =
|
||||
useState<FirebaseAuthTypes.ConfirmationResult | null>(null);
|
||||
|
||||
async function onAuthStateChanged(user: any) {
|
||||
setUser(user);
|
||||
@@ -26,16 +35,18 @@ export default function Login() {
|
||||
|
||||
async function signInWithPhoneNumber(phoneNumber: string) {
|
||||
if (!phoneNumber) {
|
||||
return Alert.alert('Please enter a valid phone number with a country code');
|
||||
return Alert.alert(
|
||||
"Please enter a valid phone number with a country code",
|
||||
);
|
||||
}
|
||||
try {
|
||||
const confirmation = await auth().signInWithPhoneNumber(phoneNumber);
|
||||
setConfirm(confirmation);
|
||||
} catch (err) {
|
||||
// TODO: implement more robust error handling by parsing err message
|
||||
console.warn(err)
|
||||
console.warn(err);
|
||||
Alert.alert(
|
||||
'There was an error. Make sure you are using a country code (ex: +1 for US)'
|
||||
"There was an error. Make sure you are using a country code (ex: +1 for US)",
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -44,7 +55,7 @@ export default function Login() {
|
||||
try {
|
||||
await confirm?.confirm(code);
|
||||
} catch {
|
||||
Alert.alert('Invalid code, please try again.');
|
||||
Alert.alert("Invalid code, please try again.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,13 +64,17 @@ export default function Login() {
|
||||
return subscriber;
|
||||
}, []);
|
||||
|
||||
|
||||
|
||||
return (
|
||||
<TouchableWithoutFeedback onPress={() => Keyboard.dismiss()}>
|
||||
<View style={{ alignItems: 'center' }}>
|
||||
<View style={{ alignItems: "center" }}>
|
||||
<TextInput
|
||||
style={{ width: '50%', height: 30, borderWidth: 1, borderColor: 'black', marginBottom: 20 }}
|
||||
style={{
|
||||
width: "50%",
|
||||
height: 30,
|
||||
borderWidth: 1,
|
||||
borderColor: "black",
|
||||
marginBottom: 20,
|
||||
}}
|
||||
placeholder="Phone"
|
||||
textContentType="telephoneNumber"
|
||||
keyboardType="phone-pad"
|
||||
@@ -69,7 +84,13 @@ export default function Login() {
|
||||
/>
|
||||
{confirm && (
|
||||
<TextInput
|
||||
style={{ width: '50%', height: 30, borderWidth: 1, borderColor: 'black', marginBottom: 20 }}
|
||||
style={{
|
||||
width: "50%",
|
||||
height: 30,
|
||||
borderWidth: 1,
|
||||
borderColor: "black",
|
||||
marginBottom: 20,
|
||||
}}
|
||||
placeholder="Code"
|
||||
keyboardType="number-pad"
|
||||
textContentType="oneTimeCode"
|
||||
@@ -77,18 +98,22 @@ export default function Login() {
|
||||
value={code}
|
||||
onChangeText={(value) => setCode(value)}
|
||||
/>
|
||||
)}
|
||||
)}
|
||||
<Button
|
||||
title={ !confirm ? "Receive code" : "Confirm code"}
|
||||
onPress={() => !confirm ? signInWithPhoneNumber(phoneNumber) : confirmCode()}
|
||||
title={!confirm ? "Receive code" : "Confirm code"}
|
||||
onPress={() =>
|
||||
!confirm ? signInWithPhoneNumber(phoneNumber) : confirmCode()
|
||||
}
|
||||
/>
|
||||
{user && (
|
||||
<>
|
||||
<Text style={{ marginTop: 10 }}>Display name: {user?.displayName}</Text>
|
||||
<Text style={{ marginTop: 10 }}>
|
||||
Display name: {user?.displayName}
|
||||
</Text>
|
||||
<Text>Phone number: {user?.phoneNumber}</Text>
|
||||
</>
|
||||
)}
|
||||
</View>
|
||||
</TouchableWithoutFeedback>
|
||||
)
|
||||
}
|
||||
);
|
||||
}
|
||||
|
Reference in New Issue
Block a user