I need to integrate the facebook sdk but without firebase. I understand firebase is the better solution but it requires some re-work on our website that we are avoiding for now.
With what I have so far, I am able to trigger the facebook login, go through the login process and return to the application. In the Application_Active sub it is hit or miss capturing the facebook token the first time, sometimes it requires a second attempt. I think I am missing an event but it is not listed anywhere that I can find. If there is an event that fires, this would solve my problem. Also I notice when the user cancels the login, the debugger prints a line "Cancelled". Is there a similar event I can use to handle the cancelled event? One other thing is I find myself having to include the iFirebaseAuth library in order to get the project to compile, are there any steps I can take to avoid including any un-necessary libraries or is iFirebaseAuth required with iFacebook? Thanks in advance.
Here is a minified test version of what I have so far:
With what I have so far, I am able to trigger the facebook login, go through the login process and return to the application. In the Application_Active sub it is hit or miss capturing the facebook token the first time, sometimes it requires a second attempt. I think I am missing an event but it is not listed anywhere that I can find. If there is an event that fires, this would solve my problem. Also I notice when the user cancels the login, the debugger prints a line "Cancelled". Is there a similar event I can use to handle the cancelled event? One other thing is I find myself having to include the iFirebaseAuth library in order to get the project to compile, are there any steps I can take to avoid including any un-necessary libraries or is iFirebaseAuth required with iFacebook? Thanks in advance.
Here is a minified test version of what I have so far:
B4X:
'Code module
#Region Project Attributes
#ApplicationLabel: Test
#Version: 1.0.0
#iPhoneOrientations: Portrait
#iPadOrientations: Portrait
#Target: iPhone, iPad
#MinVersion: 7
#QueriesSchemes: fbapi
#QueriesSchemes: fb-messenger-api
#QueriesSchemes: fbauth2
#QueriesSchemes: fbshareextension
#UrlScheme: fb9999999999999999
#End Region
Sub Process_Globals
'These global variables will be declared once when the application starts.
'Public variables can be accessed from all modules.
Public App As Application
Public NavControl As NavigationController
Private Page1 As Page
Private xui As XUI
Private facebook As FacebookSdk
Public LastOpenUrl As String = ""
End Sub
Private Sub Application_Active
If LastOpenUrl <> "" Then
Dim url As String = LastOpenUrl
LastOpenUrl = ""
If url.Contains("error=access_denied") = True Then
Log("Facebook-Login-Failed (Access Denied)")
Else
If GetFacebookToken <> "" Then
Log("Facebook-Login-Success")
Log("Token:" & GetFacebookToken)
Else
Log("Facebook-Login-Failed (No Token)")
End If
End If
End If
End Sub
Private Sub Application_OpenUrl(Url As String, Data As Object, SourceApplication As String) As Boolean
Try
Log("App-URL: " & Url)
If Url.StartsWith("fb9999999999999999://authorize") = True Then
LastOpenUrl = Url
facebook.OpenUrl(Url, Data, SourceApplication)
Else
LastOpenUrl = ""
End If
Return False
Catch
End Try
End Sub
Private Sub Application_Start (Nav As NavigationController)
NavControl = Nav
Page1.Initialize("Page1")
Page1.RootPanel.LoadLayout("Page1")
NavControl.ShowPage(Page1)
facebook.Initialize("9999999999999999")
End Sub
Private Sub GetFacebookToken As String
Try
Dim NaObj As NativeObject
NaObj = NaObj.Initialize("FBSDKAccessToken")
Return NaObj.RunMethod("currentAccessToken",Null).GetField("tokenString").AsString
Catch
Return ""
End Try
End Sub
Sub Button1_Click
facebook.SignIn
End Sub