In the latest version you can also allow signing in with mobile phone numbers.
Remember to enable this sign in method in your Firebase console.
First, collect the user’s phone number and the
recaptcha. To collect the capta, simply place
recaptchaUI
where you want it to display. Note that it will
apply only after you run the verfify
method (see
below).
Once the verify
method has run the user receives a
confirmation code that you must also capture and pass to
confirm
to confirm the authentication. The user is then
automatically logged in.
This is an overly simple, ugly example, but fully-functioning.
library(shiny)
library(firebase)
ui <- fluidPage(
useFirebase(),
textInput(
"number",
"Number"
),
actionButton("verify", "Verify"),
recaptchaUI(),
textInput("code", "Code"),
actionButton("confirm", "Confirm")
)
server <- function(input, output, session) {
f <- FirebasePhone$new()
observeEvent(input$verify, {
f$verify(input$number)
})
observeEvent(f$get_verification(), {
print(f$get_verification())
})
observeEvent(input$confirm, {
f$confirm(input$code)
})
observeEvent(f$get_confirmation(), {
print(f$get_confirmation())
})
}
shinyApp(ui, server)