Latest 9.4.5
Homepage https://github.com/Cidaas/Cidaas-Facebook
License MIT
Platforms ios 9.0
Dependencies FacebookCore, FacebookLogin, Cidaas-SDK
Authors

More about CIDaaS

To know more about Cidaas visit CIDaaS

CIDaaS Documentation

https://docs.cidaas.de/

Requirements

minSdkVersion 18

Installation

Cidaas-Facebook is available through Github. To install it, add the following line to your app level gradle file:

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

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

Add the dependency

    dependencies {
        ...
    compile 'com.github.Cidaas:cidaas-facebook:18.1.+'
    }

Creating Facebook App

The following steps are to be followed to create a Facebook App

  1. Once Gradle sync is completed, Go to the Facebook Developers Console, add a new App then give it a valid name and click "Create App Id"
  2. Take note of the App ID
  3. On the left side, you have the navigation drawer. Click Settings and then Basic
  4. Click Add Platform and Choose Android
  5. Fill the Package name, Class name and Key Hash

To know the Key Hash, Enter the following command in Terminal or Command Prompt

For windows :
    keytool -exportcert -alias androiddebugkey -keystore %HOMEPATH%.androiddebug.keystore | openssl sha1 -binary | openssl base64
For Mac :
    keytool -exportcert -alias androiddebugkey -keystore ~/.android/debug.keystore | openssl sha1 -binary | openssl base64
  1. Turn on "Single Sign On" and click "Save changes"

Getting Started

The following steps are to be followed to use this Cidaas-Facebook

  1. Mention the facebook App Id in the project’s strings.xml file
<string name="facebook_app_id">your facebook app id</string>
  1. Add the following meta data in your App’s Manifest file
<application>
    ...
    <meta-data 
        android:name="com.facebook.sdk.ApplicationId"
        android:value="@string/facebook_app_id">
    </meta-data>
</application>
  1. In your project’s Activity file Create an instance for CidaasFacebook class
CidaasFacebook cidaas;
CidaasSDK cidaas;
  1. Inside your onCreate() method, initialize the instance by passing the current activity as an argument
cidaasFacebook = new CidaasFacebook(this);
cidaas = new CidaasSDK(this);
cidaas.setURLFile(getAssets(), "properties.xml");
  1. To sign in using CidaasFacebook, call facebookLogin() method
cidaasFacebook.facebookLogin(new IAccessTokenEntity() {
    @Override
    public void onSuccess(AccessTokenEntity accessTokenEntity) {
        Toast.makeText(getApplicationContext(), accessTokenEntity.getAccessToken(), Toast.LENGTH_SHORT).show();
    }

    @Override
    public void onError(ErrorEntity errorEntity) {
        Toast.makeText(getApplicationContext(), errorEntity.getMessage(), Toast.LENGTH_SHORT).show();
    }
});
  1. Override your activity’s onActivityResult() method and redirect the received parameters to the CidaasFacebook instance’s authorize() method
cidaasFacebook.authorize(requestCode, resultCode, data);

Sample Code

activity_main.xml

    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        tools:context="com.widas.facebooksdk.MainActivity">

        <Button
            android:text="Facebook Login"
            android:id="@+id/btn_login"
            android:layout_centerHorizontal="true"
            android:layout_centerVertical="true"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />
    </RelativeLayout>

MainActivity.java

    package com.widas.facebooksdk;

    import android.content.Intent;
    import android.support.v7.app.AppCompatActivity;
    import android.os.Bundle;
    import android.view.View;
    import android.widget.Button;
    import android.widget.Toast;
    import com.widas.cidaasfacebook.CidaasFacebook;
    import com.widas.cidaasfacebook.CidaasFacebookCallback;

    public class MainActivity extends AppCompatActivity {
        public CidaasFacebook cidaas;

        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
            cidaas = new CidaasFacebook(this, getString(R.string.facebook_app_id));
            Button btn_login = (Button) findViewById(R.id.btn_login);
            btn_login.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    cidaas.signIn();
                }
            });
        }

        @Override
        protected void onActivityResult(int requestCode, int resultCode, Intent data) {
            CidaasFacebook.facebookCallback = new CidaasFacebookCallback() {
                @Override
                public void onSuccess(String message) {
                    Toast.makeText(getApplicationContext(), "Access Token :" + message, Toast.LENGTH_LONG).show();
                }
                @Override
                public void onCancel(String message) {
                    Toast.makeText(getApplicationContext(), message, Toast.LENGTH_LONG).show();
                }
                @Override
                public void onError(String message) {
                    Toast.makeText(getApplicationContext(), message, Toast.LENGTH_LONG).show();
                }
            };
            cidaas.authorize(requestCode, resultCode, data);
            super.onActivityResult(requestCode, resultCode, data);
        }
    }

Screen Shots

Screen 1Screen 2

Help and Support

For more support visit CIDaaS Support

Latest podspec

{
    "name": "Cidaas-Facebook",
    "version": "9.4.5",
    "summary": "A short description of Cidaas-Facebook.",
    "description": "TODO: Add long description of the pod here.",
    "homepage": "https://github.com/Cidaas/Cidaas-Facebook",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Cidaas": "[email protected]"
    },
    "source": {
        "git": "https://github.com/Cidaas/cidaas-facebook-ios.git",
        "tag": "9.4.5"
    },
    "platforms": {
        "ios": "9.0"
    },
    "source_files": "Cidaas-Facebook/Classes/**/*",
    "dependencies": {
        "FacebookCore": [
            "0.3.0"
        ],
        "FacebookLogin": [
            "0.3.0"
        ],
        "Cidaas-SDK": [
            "~> 9.4"
        ]
    },
    "pushed_with_swift_version": "3.0"
}

Pin It on Pinterest

Share This