I am developing an android application where i have redirected to https://m.facebook.com/ inside a web-view.
What is required?
I want to check the login status, once login is successfully done and user is on home page i want to handle visibility of some views and redirect webview to another URL which is facebook video link.
What i have tried?
I have tried checking URLs in onLoadResource and found some URLs that we get on successful login and logout. But its still not enough as Facebook login can be done via different methods (i.e by number, by email, by already saved account etc).
To check Logout:
fun isFacebookLoggedOut(url: String?): Boolean {
return url?.startsWith("https://m.facebook.com/?stype=lo&jlou")!!
}
To check Login:
fun isFacebookLoggedIn(url: String?): Boolean {
if (url.equals("https://m.facebook.com/login/save-device/?login_source=login#_=_") || url.equals(
"https://m.facebook.com/login/save-device/cancel/?flow=interstitial_nux_retry&nux_source=regular_login"
) || url?.contains("https://m.facebook.com/login/device-based/validate-pin/?refid=")!!
|| url.startsWith("https://m.facebook.com/login/device-based/login/async/?") || url.startsWith(
"https://m.facebook.com/login/account_recovery/name_search/?flow=initiate_view&ls=initiate_view"
)
) {
return true
} else {
return false
}
}
This works in some cases and on some devices but there are scenarios when user log in with contact number, or saved account which goes through different phases like entering credentials then verifying any code if browser is new and so on.
Is there any method or proper way to track login status thats perfect for each scenario and each device?
Can somebody please help me out with this. Any help will be appreciated
You can visit this link to have all the detailed information to implement the Facebook SDK and be able to login to Facebook throught your app.