hello everyone !
I am using the firebase for user authentication of my application, however, in order for the firebase to return the information to the sub: Sub auth_SignedIn (User As FirebaseUser), it is necessary to call the function: Starter.auth.SignInWithGoogle several times until the function: Sub auth_SignedIn (User As FirebaseUser), is accessed ...
this is the activity code in question :
this is the debug screenshots :
*(this is the screenshot of the numerous requisitions before entering the function: ' Sub auth_SignedIn (User As FirebaseUser) '
*(this is the screenshot of when I add a 'Limiter' so that the function: ' Starter.auth.SignInWithGoogle ', be called only once ) the application stays stuck forever ...
the firebase never enters the function: Sub auth_SignedIn (User As FirebaseUser), so that the information of this due user is stored .
Does anyone have a solution to do away with the many requests?
I am using the firebase for user authentication of my application, however, in order for the firebase to return the information to the sub: Sub auth_SignedIn (User As FirebaseUser), it is necessary to call the function: Starter.auth.SignInWithGoogle several times until the function: Sub auth_SignedIn (User As FirebaseUser), is accessed ...
this is the activity code in question :
B4X:
#Region Project Attributes
#ApplicationLabel: MyApp
#VersionCode: 1
#VersionName:
'SupportedOrientations possible values: unspecified, landscape or portrait.
#SupportedOrientations: portrait
#CanInstallToExternalStorage: True
#End Region
#Region Activity Attributes
#FullScreen: True
#IncludeTitle: False
#End Region
#BridgeLogger: true
Sub Process_Globals
Public ApplicationVersion As Int = 1
Public ServerUrl As String = "192.168.0.1:51063"
Public UserEmail As String = ""
Public UserName As String = ""
Private timerM As Int = 0
Public Startup As Boolean = True
'Private auth As FirebaseAuth
Private RequestsNum As Int = 0
End Sub
Sub Globals
Private auth As FirebaseAuth
End Sub
Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
'Startup = FirstTime
UserEmail = ""
UserName = ""
RequestsNum = 0
Startup = Starter.Startup
' auth.Initialize("auth")
If (Startup = True) Then
Startup = True
Starter.Startup = True
Activity.LoadLayout("splash")
Do While (Starter.ServerIsConnected = False)
Log(timerM)
Sleep(1000)
timerM = timerM + 1
If (timerM = 15) Then
Msgbox("Não foi possível se conectar ao servidor !","Houve um problema ...")
ExitApplication
End If
Loop
If Starter.auth.CurrentUser.IsInitialized Then
Log("FirstTime")
Sleep(5000)
auth_SignedIn(Starter.auth.CurrentUser)
Else
LogColor("Starter = "&Starter.Startup ,Colors.Green)
If (Starter.RequestedAuth = False) Then
Starter.auth.SignInWithGoogle
Else
LogColor("Tentativa de Request",Colors.Red)
End If
End If
Else
Startup = False
Starter.Startup = False
Do While (Starter.ServerIsConnected = False)
Log(timerM)
Sleep(1000)
timerM = timerM + 1
If (timerM = 15) Then
Msgbox("Não foi possível se conectar ao servidor !","Houve um problema ...")
ExitApplication
End If
Loop
If Starter.auth.CurrentUser.IsInitialized Then
Log("NoFirstTime")
'Sleep(5000)
auth_SignedIn(Starter.auth.CurrentUser)
Else
LogColor("Starter = "&Starter.Startup ,Colors.Green)
If (Starter.RequestedAuth = False) Then
Starter.auth.SignInWithGoogle
Else
LogColor("Tentativa de Request",Colors.Red)
End If
End If
End If
End Sub
Sub auth_TokenAvailable (User As FirebaseUser, Success As Boolean, TokenId As String)
LogColor("returnFB = "&Success,Colors.Blue)
Log("tokenID = "&TokenId)
End Sub
Sub auth_SignedIn (User As FirebaseUser)
Starter.RequestedAuth = True
Log("SignedIn: " & User.DisplayName)
Log(User.Email)
Log(User.PhotoUrl)
UserEmail = User.Email
UserName = User.DisplayName
Starter.LoggedMail = UserEmail
Starter.LoggedNome = UserName
Starter.LoggedPhoto = User.PhotoUrl
End Sub
Sub Activity_Resume
For Each v As View In Activity.GetAllViewsRecursive
If v.Tag Is B4XLoadingIndicator And v.Visible = True Then
Dim x As B4XLoadingIndicator = v.Tag
x.Show
End If
Next
Log("Resumed run")
Do While (Starter.ServerIsConnected = False)
Log(timerM)
Sleep(1000)
timerM = timerM + 1
If (timerM = 15) Then
Msgbox("Não foi possível se conectar ao servidor !","Houve um problema ...")
ExitApplication
End If
Loop
If Starter.auth.CurrentUser.IsInitialized Then
Log("entrou aqui porra")
If (Startup = True) Then
Sleep(5000)
End If
auth_SignedIn(Starter.auth.CurrentUser)
Else
LogColor("Starter = "&Starter.Startup ,Colors.Green)
If (Starter.RequestedAuth = True) Then
LogColor("AuthID = "&Starter.auth.CurrentUser,Colors.Blue)
End If
If (Starter.RequestedAuth = False) Then
Starter.auth.SignInWithGoogle
Else
LogColor("Tentativa de Request",Colors.Red)
End If
End If
If (UserEmail <> "") Then
Log("logado !")
Dim data As Map
data.Initialize
data.Put("message", UserEmail)
Starter.wsh.SendEventToServer("Device_UserAuthenticate", data)
data.Clear
End If
End Sub
Sub ToRegistro()
StartActivity(Registro)
SetAnimation("right_left1","right_left")
Activity.Finish
End Sub
Sub ToApp()
StartActivity(App)
SetAnimation("right_left1","right_left")
Activity.Finish
End Sub
Sub Blocked()
Msgbox("Esta conta está permanentemente bloqueada !","Encontramos um problema !")
ExitApplication
End Sub
Sub Error0()
Msgbox("Houve um erro interno , não foi possível concluir a autenticação !","Erro na autenticação")
ExitApplication
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub SetAnimation(InAnimation As String, OutAnimation As String)
Dim r As Reflector
Dim package As String
Dim In, out As Int
package = r.GetStaticField("anywheresoftware.b4a.BA", "packageName")
In = r.GetStaticField(package & ".R$anim", InAnimation)
out = r.GetStaticField(package & ".R$anim", OutAnimation)
r.Target = r.GetActivity
r.RunMethod4("overridePendingTransition", Array As Object(In, out), Array As String("java.lang.int", "java.lang.int"))
End Sub
this is the debug screenshots :
*(this is the screenshot of the numerous requisitions before entering the function: ' Sub auth_SignedIn (User As FirebaseUser) '
*(this is the screenshot of when I add a 'Limiter' so that the function: ' Starter.auth.SignInWithGoogle ', be called only once ) the application stays stuck forever ...
the firebase never enters the function: Sub auth_SignedIn (User As FirebaseUser), so that the information of this due user is stored .
Does anyone have a solution to do away with the many requests?