How to add Social Media Sign Up Library in Android?

0
291

Social Media Sign up is a simple android library that makes the sign up integration with the most famous social media platforms more powerful and easier than you could imagine.

Nowadays most of the mobile apps are integrating with the most famous social media platforms (Facebook, Instagram, Twitter, Google Plus and LinkedIn). For the developer, it’s going to be a hassle to communicate with all of these platforms.

Front page : Social Media Sign Up Library in Android
Front page : Social Media Sign Up Library in Android

So, Social Media Sign Up library makes the magic for you, with only one line of code, you can integrate with the most famous social media platform :

And get the user data without handling anything from your side. SO EASY SO SIMPLE.

Facebook Tabbed Login : Social Media Sign Up Library in Android
Facebook Tabbed Login : Social Media Sign Up Library in Android

1Features

  • Sign up with the most famous social media platforms which are :
    • Facebook
    • Instagram
    • Twitter
    • Google Plus
    • LinkedIn
LinkdIn profile : Social Media Sign Up Library in Android
LinkdIn profile : Social Media Sign Up Library in Android
  • Adding scopes for each platform according to the application needs.
  • Support default scopes to get the minimum user data.
  • Used inside ActivityFragment or event Custom View.
  • Update the social media sdk versions in gradle file of your application, which guarantee the up-to-date social media sdk versions.
  • Adding the social media publicsecret and application keys in the gradle file of your application to guarantee the totally isolation between the library and the integrated application.
  • No need to add anything in Manifest.xml file, we did all of these to you in SocialMediaSignUp library ;).
  • Easily integration, with only one line of code, you will have the user data starting from access token to personal data like name, email and profile picture.

2Benefits

  • Hassle of integration with more that four social media platforms.
  • Increase isolation, good code structure and separation.
  • Easy integration, with only one line of code, and that’s enough ;).

3Installation

For Gradle :

Step 1 : Add it in your root build.gradle at the end of repositories:

allprojects {
    repositories {
      ...
      maven { url 'https://jitpack.io' }
    }
  }

Step 2 : Add the dependency

dependencies {
          implementation 'com.github.ahmed-adel-said:socialmediasignup:v1.0'
  }

For Maven :

Step 1 : Add it in your root build.gradle at the end of repositories:

<repositories>
    <repository>
        <id>jitpack.io</id>
        <url>https://jitpack.io</url>
    </repository>
  </repositories>

Step 2. Add the dependency

<dependency>
      <groupId>com.github.ahmed-adel-said</groupId>
      <artifactId>socialmediasignup</artifactId>
      <version>-v1.0</version>
  </dependency>

4Download

Download the source code and working example below:

5Documentation “The first two points are mandatory”:

  1. To add your public, secret and application keys for every social media platform, all you have to do is to override the default values that the library has and put or own values in the build.gradle file app of your app module :
android.defaultConfig.manifestPlaceholders = [
        facebookAppId         : "FACEBOOK_APP_ID",
        googleWebClientId     : "GOOGLE_WEB_CLIENT_ID",
        twitterConsumerKey    : "TWITTER_CONSUMER_KEY”,
        twitterConsumerSecret : "TWITTER_CONSUMER_SECRET",
        instagramClientId     : "INSTAGRAM_CLIENT_KEY",
        instagramClientSecret : "INSTAGRAM_CLIENT_SECRET",
        instagramRedirectUri  : "INSTAGRAM_REDIRECT_URI"
]

2. You must add the social media sdk versions by yourself in the build.gradle file of the project module. Since our SocialMediaSignUp library will wait them from you to be your mission to always making the social media sdk versions up-to-date :

ext {
    socialMediaSignUpLibraries = [
            facebookVersion  : '4.30.0',
            googlePlusVersion: '11.8.0',
            twitterVersion   : '3.2.0'
    ]
}

3. If you want to get user data of any of the five social media platforms, all you have to do is to write this one line of code :

/**
 * @param socialMediaType is enum class that has types of all social media platforms.
 * @param scopes that can be passed to each social media platform.
 * @param callback that will be fired once there is success, error, or sign out happens during the connection with any social media platform.
 */
SocialMediaSignUp.getInstance().connectTo(SocialMediaType socialMediaType, List<String> scopes, SocialMediaSignUpCallback callback);
/**
 * This is only for connecting with LinkedIn social media platform.
 * @param linkedInScope that will be passed to LinkedIn social media platform.
 * @param callback that will be fired once there is success, error, or sign out happened during the connection with LinkedIn social media platform.
 */
SocialMediaSignUp.getInstance().connectToLinkedIn(Scope linkedInScope, SocialMediaSignUpCallback callback);

4. While if you want to disconnect the connection between any of the five social media platforms, here is how can you make it :

/**
 * @param socialMediaType is enum class that has types of all social media platforms.
 * @param callback that will be fired once there is success, error, or sign out happens during the connection with any social media platform.
 */
SocialMediaSignUp.getInstance().disconnectService(SocialMediaType socialMediaType, SocialMediaSignUpCallback callback);

5. Here is the SocialMediaType enum class :

enum SocialMediaType {
        FACEBOOK("facebook"),
        GOOGLE_PLUS("google_plus"),
        TWITTER("twitter"),
        INSTAGRAM("instagram"),
        LINKEDIN("linkedin");
    }
  1. And the SocialMediaSignUpCallback interface :
public interface SocialMediaSignUpCallback {
    void onSuccess(SocialMediaSignUp.SocialMediaType socialMediaType, SocialMediaUser socialMediaUser);
    void onError(Throwable error);
    void onSignOut(SocialMediaSignUp.SocialMediaType socialMediaType);
}

Hope you enjoy this article and if it’s true then please share with your friends.

 

Share your thoughts

Loading Facebook Comments ...
Loading Disqus Comments ...