I've seen a lot of projects that show how to implement login in MVP, but can't find anything related to Google/Facebook login.
What should we do in the case when login flow is strongly bound to Android components life cycle? I see the main benefit of MVP in that we build an abstraction above Context
, but this abstraction will appear too complex when we need to follow, for example, Facebook login flow: you need to register FacebookCallback
with CallbackManager
, call logInWithReadPermissions()
(passing Activity/Fragment to it), delegate onActivityResult()
to callbackManager
and this will trigger FacebookCallback's methods.
What I have on mind is to create something like
interface AuthInteractor {
void doFacebookLogin();
void doGoogleLogin();
}
whose implementation will know about Context and initialize GoogleApiClient
. It will be injected in Presenter, but what with all this callbacks (especially in Facebook's SDK) things are going to become too complicated. Isn't it better to omit MVP in such cases?
I guess you're asking this question because you're trying to merge two "ideas" to a single one in your head:
I stumbled upon similar issues about two years ago when I researched MVP implementations in Android, and I came to a conclusion that the only way to settle all issues of this kind is to abandon the idea of Activity/Fragment being MVP views.
I posted a detailed discussion of this issue in this post: Why Activities in Android are not UI Elements
And there is also a tutorial on how to implement a better MVP in Android: MVP and MVC in Android
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With