Android SDK Setup

(Difference between revisions)
Jump to: navigation, search
(Get your Social-ID data)
Line 1: Line 1:
= Existing Project =
+
= 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.
 
+
Import the zip file's contents into your existing Android project by extracting it into your "libs" folder. If your project does not already have a "libs" folder, create one at the root of the project by right-clicking the project and choosing "New" and then "Folder."
+
  
 
[http://dev.socialidnow.com/index.php/Android_SDK_Download Download the SDK]
 
[http://dev.socialidnow.com/index.php/Android_SDK_Download Download the SDK]
  
== Get your Social-ID data ==
+
= Get your Social-ID data =
  
You'll need 5 variables to configure the SDK:
+
You'll need 3 variables to configure the SDK:
  
 
* SENDER_ID: Set up a project on Google Developers Console - https://console.developers.google.com/project. Get your project number. This will be used as the SENDER_ID in the SDK.
 
* SENDER_ID: Set up a project on Google Developers Console - https://console.developers.google.com/project. Get your project number. This will be used as the SENDER_ID in the SDK.
* LOGIN_APP_API_KEY: Set up a Social-ID LoginApp at: https://app.socialidnow.com/marketing/login/apps. Your key is the id of the app. This will be used as the LOGIN_APP_API_KEY in the SDK.
+
* LOGIN_APP_ID: Set up a Social-ID LoginApp at: https://app.socialidnow.com/marketing/login/apps. Your key is the id of the app. This will be used as the LOGIN_APP_ID in the SDK.
* LOGIN_APP_API_SECRET: The secret can be found on the Call the API menu - https://app.socialidnow.com/marketing/login/apps/APP_ID/apis. This will be used as the LOGIN_APP_API_SECRET in the SDK.
+
* LOGIN_APP_CLIENT_SECRET: The client secret can be found on the Call the API menu - https://app.socialidnow.com/marketing/login/apps/APP_ID/apis. This will be used as the LOGIN_APP_CLIENT_SECRET in the SDK.
* API_KEY: The API_KEY can be found at: https://app.socialidnow.com/marketing/apis.
+
* API_SECRET: The API_SECRET can be found at: https://app.socialidnow.com/marketing/apis.
+
  
== Add the SDK to your app ==
+
= Add the SDK to your app =
  
 
Add the following import statements to your Activity:
 
Add the following import statements to your Activity:
Line 26: Line 22:
 
Call SocialId.config from the onCreate method of your Activity class to set your application Social-ID configuration:
 
Call SocialId.config from the onCreate method of your Activity class to set your application Social-ID configuration:
  
   SocialId.config(this, "SENDER_ID", "API_KEY", "API_SECRET", "LOGIN_APP_API_KEY", "LOGIN_APP_API_SECRET");
+
   SocialId.config(this, "SENDER_ID", "LOGIN_APP_ID", "LOGIN_APP_CLIENT_SECRET");
  
Add the following variables to res/values/strings.xml:
+
Add the following variable to the ''res/values/strings.xml'' file:
 +
  <!-- Facebook App ID -->
 +
  <string name="app_id">FACEBOOK_APP_ID</string>
  
   <string name="app_id"></string> <!-- Facebook App ID -->
+
Add the following content to the ''assets/oauth_consumer.properties'' file. Ensure the ''assets'' folder is at the same level as the ''res'' folder.
   <string name="client_id"></string> <!-- Google Client ID -->
+
  #twitter
   <string name="client_secret"></string> <!-- Google Client Secret -->
+
   twitter.com.consumer_key = TWITTER_CONSUMER_KEY
 +
   twitter.com.consumer_secret = TWITTER_CONSUMER_SECRET
 +
    
 +
  #linkedin
 +
  api.linkedin.com.consumer_key = LINKEDIN_CLIENT_ID
 +
  api.linkedin.com.consumer_secret = LINKEDIN_CLIENT_SECRET
  
== Modify app manifest ==
+
= Modify app manifest =
  
Add the following definitions to AndroidManifest.xml immediately before opening the <application> tag:
+
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.INTERNET" />
 
   <uses-permission android:name="android.permission.GET_ACCOUNTS" />
 
   <uses-permission android:name="android.permission.GET_ACCOUNTS" />
 
   <uses-permission android:name="android.permission.USE_CREDENTIALS" />
 
   <uses-permission android:name="android.permission.USE_CREDENTIALS" />
 
+
 
 
   <nowiki><!-- BEGIN: use this if you need push notification support --></nowiki>
 
   <nowiki><!-- BEGIN: use this if you need push notification support --></nowiki>
 
   <uses-permission android:name="android.permission.WAKE_LOCK" />
 
   <uses-permission android:name="android.permission.WAKE_LOCK" />
Line 53: Line 56:
 
   <nowiki><!-- END: use this if you need push notification support --></nowiki>
 
   <nowiki><!-- END: use this if you need push notification support --></nowiki>
  
Add the following definitions to AndroidManifest.xml inside the <application> tag:
+
Add the following definitions to AndroidManifest.xml inside the ''<application>'' tag:
  
 
   <meta-data
 
   <meta-data
Line 61: Line 64:
 
       android:name="com.facebook.sdk.ApplicationId"
 
       android:name="com.facebook.sdk.ApplicationId"
 
       android:value="@string/app_id" />
 
       android:value="@string/app_id" />
  <meta-data
 
      android:name="com.coffeebeantech.socialidsdk.client_id"
 
      android:value="@string/client_id" />
 
  <meta-data
 
      android:name="com.coffeebeantech.socialidsdk.client_secret"
 
      android:value="@string/client_secret" />
 
 
   <activity android:name="com.facebook.LoginActivity" >
 
   <activity android:name="com.facebook.LoginActivity" >
 
   </activity>
 
   </activity>
 
+
    
   <nowiki><!-- BEGIN: use this if you need push notification support --></nowiki>
+
  <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" />
+
  <nowiki><!-- END: use this if you need push notification support --></nowiki>
+
 
+
= New Project =
+
 
+
== Download & unzip the sample project ==
+
 
+
[http://www.example.com Download the project]
+
 
+
== Add the project to your workspace ==
+
 
+
Unzip the file and move the socialid-sample-android into your workspace directory.
+
 
+
In Eclipse, go to File → Import…
+
 
+
Click General → Existing Projects into Workspace
+
 
+
Make sure the "Select root directory" radio button is selected, and browse to your workspace directory.
+
 
+
In the Projects box, check the box next to ParseStarterProject and click Finish. (Note: if your workspace isn't already set up for Android, you may need to specify the location of the Android SDK in the Android tab in preferences, in order to get the project to compile.)
+
 
+
== Get your Social-ID data ==
+
 
+
You will need 5 variables to configure the SDK:
+
 
+
* SENDER_ID: Set up a project on Google Developers Console - https://cloud.google.com/console/project. Get your project number. This will be used as the SENDER_ID in the SDK.
+
* LOGIN_APP_API_KEY: Set up a Social-Id LoginApp at: https://app.socialidnow.com/marketing/login/apps. Your key is the id of the app. This will be used as the LOGIN_APP_API_KEY in the SDK.
+
* LOGIN_APP_API_SECRET: The secret can be found on the Call the API menu - https://app.socialidnow.com/marketing/login/apps/APP_ID/apis. This will be used as the LOGIN_APP_API_SECRET in the SDK.
+
* API_KEY: The API_KEY can be found at: https://app.socialidnow.com/marketing/apis.
+
* API_SECRET: The API_SECRET can be found at: https://app.socialidnow.com/marketing/apis.
+
 
+
== Add the SDK to 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 Application class to set your application SocialID configuration:
+
 
+
  SocialId.config(this, "SENDER_ID", "API_KEY", "API_SECRET", "LOGIN_APP_API_KEY", "LOGIN_APP_API_SECRET");
+
 
+
Add the following variables to res/values/strings.xml:
+
 
+
  <string name="app_id"></string> <!-- Facebook App ID -->
+
  <string name="client_id"></string> <!-- Google Client ID -->
+
  <string name="client_secret"></string> <!-- Google 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" />
+
 
+
  <nowiki><!-- BEGIN: use this if you need push notification support --></nowiki>
+
  <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" />
+
  <nowiki><!-- END: use this if you need push notification support --></nowiki>
+
 
+
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="com.coffeebeantech.socialidsdk.client_id"
+
      android:value="@string/client_id" />
+
  <meta-data
+
      android:name="com.coffeebeantech.socialidsdk.client_secret"
+
      android:value="@string/client_secret" />
+
  <activity android:name="com.facebook.LoginActivity" >
+
  </activity>
+
 
+
 
   <nowiki><!-- BEGIN: use this if you need push notification support --></nowiki>
 
   <nowiki><!-- BEGIN: use this if you need push notification support --></nowiki>
 
   <receiver
 
   <receiver

Revision as of 19:11, 17 September 2015

Contents

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.

Download the SDK

Get your Social-ID data

You'll need 3 variables to configure the SDK:

Add the SDK to 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:

 SocialId.config(this, "SENDER_ID", "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.

 #twitter
 twitter.com.consumer_key = TWITTER_CONSUMER_KEY
 twitter.com.consumer_secret = TWITTER_CONSUMER_SECRET
 
 #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" />
 <activity android:name="com.facebook.LoginActivity" >
 </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