Android SDK Setup

From Social ID Developers
Revision as of 16:30, 3 August 2017 by Gabriel.prado (Talk | contribs)
Jump to: navigation, search

Contents

Download the SDK

Download the SDK

Import the AAR file into your existing AndroidStudio as a new module and update your project and app .gradle files to include the new module.

Project settings.gradle file:

 include ':socialidsdk'

App specific app/build.gradle file:

 dependencies {
   compile project(':socialidsdk')
 }

Get your Social-ID data

You'll need 3 variables to configure the SDK:

Add Facebook SDK to your app

Add the Facebook maven repository to your app/build.gradle before the dependencies area and add the latest Facebook SDK dependency to your list of dependencies:

 repositories {
   mavenCentral() 
 }
 
 dependencies { 
   compile 'com.facebook.android:facebook-android-sdk:4.7.0'
 }

Add Twitter Fabric SDK to your app

You can find Fabric installation steps in their official page: [1].

After adding the Fabric plugin to AndroidStudio, add the following configurations to your app/build.gradle file (or follow Fabric's setup guide):

 buildscript {
   repositories {
     maven { url 'https://maven.fabric.io/public' }
   }
 
   dependencies {
     classpath 'io.fabric.tools:gradle:1.+'
   }
 }
 
 apply plugin: 'io.fabric'
 
 repositories {
   maven { url 'https://maven.fabric.io/public' }
 }
 
 dependencies {
   compile('com.twitter.sdk.android:twitter:1.8.0@aar') {
     transitive = true;
   }
 }

Configure Social-ID SDK in your app

Add the following import statements to your Activity:

 import com.coffeebeantech.socialidsdk.SocialId;
 import com.coffeebeantech.socialidsdk.notification.NotificationParameters;

Call SocialId.config from the onCreate method of your Activity class to set your application Social-ID configuration:

 //with push notifications support
 SocialId.config(this, "SENDER_ID", "LOGIN_APP_ID", "LOGIN_APP_CLIENT_SECRET");
 //without push notifications support
 SocialId.config(this, "LOGIN_APP_ID", "LOGIN_APP_CLIENT_SECRET");

Add the following variable to the res/values/strings.xml file:

 <string name="app_id">FACEBOOK_APP_ID</string>

Add the following content to the assets/oauth_consumer.properties file. Ensure the assets folder is at the same level as the res folder.

 #linkedin
 api.linkedin.com.consumer_key = LINKEDIN_CLIENT_ID
 api.linkedin.com.consumer_secret = LINKEDIN_CLIENT_SECRET

Modify app manifest

Add the following definitions to AndroidManifest.xml immediately before opening the <application> tag:

 <uses-permission android:name="android.permission.INTERNET" />
 <uses-permission android:name="android.permission.GET_ACCOUNTS" />
 <uses-permission android:name="android.permission.USE_CREDENTIALS" />
 
 <!-- BEGIN: use this if you need push notification support -->
 <uses-permission android:name="android.permission.WAKE_LOCK" />
 <uses-permission android:name="android.permission.VIBRATE" />
 <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
 <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
 <permission
     android:name="com.YOUR_PACKAGE.C2D_MESSAGE"
     android:protectionLevel="signature" />    
 <uses-permission android:name="com.YOUR_PACKAGE.C2D_MESSAGE" />
 <!-- END: use this if you need push notification support -->

Add the following definitions to AndroidManifest.xml inside the <application> tag:

 <meta-data
     android:name="com.google.android.gms.version"
     android:value="@integer/google_play_services_version" />
 <meta-data
     android:name="com.facebook.sdk.ApplicationId"
     android:value="@string/app_id" />
 <meta-data
     android:name="io.fabric.ApiKey"
     android:value="FABRIC_API_KEY" />
 
 <activity android:name="com.facebook.FacebookActivity"
     android:theme="@android:style/Theme.Translucent.NoTitleBar"
     android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation"
     android:label="@string/app_name" />
 </activity>
 
 <!-- BEGIN: use this if you need push notification support -->
 <receiver
     android:name="com.coffeebeantech.socialidsdk.notification.NotificationReceiver"
     android:permission="com.google.android.c2dm.permission.SEND" >
     <intent-filter>
         <action android:name="com.google.android.c2dm.intent.RECEIVE" />
         <category android:name="com.YOUR_PACKAGE" />
     </intent-filter>
 </receiver>
 <receiver
     android:name="com.coffeebeantech.socialidsdk.registration.ConnectivityMonitor"
     android:enabled="false" >
     <intent-filter>
         <action android:name="android.net.conn.CONNECTIVITY_CHANGE" />
         <category android:name="com.YOUR_PACKAGE" />
     </intent-filter>
 </receiver>
 <service android:name="com.coffeebeantech.socialidsdk.notification.NotificationService" />
 <service android:name="com.coffeebeantech.socialidsdk.registration.RegistrationService" />
 <!-- END: use this if you need push notification support -->
Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox