Skip to content
This repository has been archived by the owner on Jul 28, 2022. It is now read-only.

Android library that makes easier to use a main features from Facebook SDK (login & share).

License

Notifications You must be signed in to change notification settings

mobiledevpro/facebook-login-share

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Facebook Login & Share module

This module makes easier to use a main Facebook features (login & share)

Init module

  • Main Application class:
public class App extends Application {

    private static final String FACEBOOK_APP_ID = "APP ID from Facebook Developer Console";
    
    ..........
    
    @Override
    public void onCreate() {
        super.onCreate();

        //init facebook helper
        FBLoginShareHelper.getInstance().init(this, FACEBOOK_APP_ID);
    }
    
  
}
  • App-level build.gradle
dependencies {
   ...............
   ...............
   
   compile project(':facebook-login-share')
}

Login. Get access to Facebook Page to publish content.

  • Start login from fragment:
FBLoginShareHelper.getInstance().loginAsPageAdmin(fragment, new IFBLoginShareHelper.IFBLoginResultCallbacks() {
    @Override
    public void onSuccess(String accessToken, final String userOrPageName, String userOrPageId) {
       //here your code
    }

    @Override
    public void onFail(String message) {
       //show error
       Toast.makeText(mView.getActivity(), message, Toast.LENGTH_SHORT).show();
    }
});
  • Handle result from onActivityResult() in the fragment:
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    switch (requestCode) {
        ................
        ................
        ................
            
        case FBLoginShareHelper.REQUEST_CODE:
            FBLoginShareHelper.getInstance().onLoginResult(requestCode, resultCode, data);
            break;
    }
}

ezgif-5-5ed0eacacb

Logout

FBLoginShareHelper.getInstance().logout();

Upload video to Facebook page.

FBLoginShareHelper.getInstance().uploadVideoToPageAsync(
    "[page access token string]",
    "[page id]",
    [video file here],
    "[Video title here]",
    "[Video description here]",
    new IFBLoginShareHelper.IFBVideoUploadResultCallbacks() {
        @Override
        public void onSuccess() {
              //your code
        }

        @Override
         public void onFail(String message) {
              //your code
         }
    }
);

About

Android library that makes easier to use a main features from Facebook SDK (login & share).

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages