Ask for advice - How do I convert the Facebook SDK to Clean Architecture on Android?

I am using Clean Architecture in my project. Now I want to integrate a feature that asks the Facebook SDK to sign in.

Im my opinion, the Facebook SDK acts as a data provider (which provides an authentication service, similar to the other Restful login API) and should be configured and used in the module datainstead of the module app. For example, if I want to log in to Facebook, I will choose the appropriate use case, then such a use case will call the module datato do the actual work.

But the problem is with the Facebook method (see Facebook LoginManager, here ) to launch an Activity / Fragment instance.

So, should I move the Facebook SDK back to the module appor pass an Activity instance to the storagemodule?

I do not like their options. (felling is not happy, although it helps to resolve the demand). Anyone have a better approach? Thanks

+4
source share
1 answer

In order to strictly follow a clean architecture, you must keep all the frames outside the inner circles of ur (application module). This includes the Facebook SDK as well as Android.

The usual way to access frameworks from business rules in Clean Architecture is through abstractions.

:

  • IActivity /
  • ILoginManager , IActivity
  • AndroidActivity, IActivity
  • FacebookLoginManager, ILoginManager
  • - IActivity FacebookLoginManager ILoginManager
  • FacebookLoginManager IActivity android LoginManager Facebook SDK

ur, .

0

Source: https://habr.com/ru/post/1689226/


All Articles