IOS SDK Setup

(Difference between revisions)
Jump to: navigation, search
(Setup FacebookSDK (if you didn't already))
Line 1: Line 1:
= Existing Project =
+
= Download the SDK =
 
+
== Download the SDK ==
+
  
 
Extract the zip file's contents and drag & drop the SocialID.framework file to the "Frameworks" folder in your XCode project.
 
Extract the zip file's contents and drag & drop the SocialID.framework file to the "Frameworks" folder in your XCode project.
Line 7: Line 5:
 
[http://dev.socialidnow.com/index.php/iOS_SDK_Download Download the SDK]
 
[http://dev.socialidnow.com/index.php/iOS_SDK_Download Download the SDK]
  
== Setup FacebookSDK (if you didn't already) ==
+
= Setup Facebook iOS SDK =
  
Follow the instructions [https://developers.facebook.com/docs/ios/getting-started/ here].
+
Follow the instructions [https://developers.facebook.com/docs/ios/getting-started/ here] if you didn't already.
  
 
You need to follow the steps 4 and 5:
 
You need to follow the steps 4 and 5:
  
4. [https://developers.facebook.com/docs/ios/getting-started#addSDK Add the SDK to your Xcode Project]
+
* 4. [https://developers.facebook.com/docs/ios/getting-started#addSDK Add the SDK to your Xcode Project]
  
5. [https://developers.facebook.com/docs/ios/getting-started#xcode Configure Xcode Project]
+
* 5. [https://developers.facebook.com/docs/ios/getting-started#xcode Configure Xcode Project]
  
 
The other steps are optional. You can follow them if you want to explore more features from Facebook SDK.
 
The other steps are optional. You can follow them if you want to explore more features from Facebook SDK.
  
== Setup GoogleSDK (if you didn't already) ==
+
= Setup Google iOS SDK =
  
Follow the instructions [https://developers.google.com/+/mobile/ios/getting-started here]. It is important to follow the instructions to the letter (set up all required frameworks, set -ObjC under "Other Linker Flags", etc.).
+
Follow the instructions [https://developers.google.com/+/mobile/ios/getting-started here] if you didn't already. It is important to follow the instructions to the letter (set up all required frameworks, set -ObjC under "Other Linker Flags", etc.).
  
== Get your Social-ID data ==
+
= Get your SocialID Data =
  
You will need 4 variables to configure the SDK:
+
You will need 2 variables to configure the SDK:
  
 
* applicationId: Set up a Social-Id LoginApp at: https://app.socialidnow.com/marketing/login/apps. Your key is the id of the app.
 
* applicationId: Set up a Social-Id LoginApp at: https://app.socialidnow.com/marketing/login/apps. Your key is the id of the app.
* applicationSecret: The secret can be found on the Call the API menu - https://app.socialidnow.com/marketing/login/apps/APP_ID/apis.
+
* applicationClientSecret: The API client secret can be found on the Call the API menu - https://app.socialidnow.com/marketing/login/apps/APP_ID/apis.
* marketingAccountId: This can be found at: https://app.socialidnow.com/marketing/apis.
+
* marketingAccountSecret: This can be found at: https://app.socialidnow.com/marketing/apis.
+
  
== Add the SDK to your app ==
+
= Setup the Social-ID SDK into your app =
  
 
Add the following statement to your ViewController:
 
Add the following statement to your ViewController:
Line 38: Line 34:
 
   #import <SocialID/SocialID.h>
 
   #import <SocialID/SocialID.h>
  
Add the following code to your app delegate header file:
+
Add the following code to the "(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions" method in your App Delegate implementation file:
  
   #import <GooglePlus/GooglePlus.h>
+
   // Initialize SocialID SDK (use the data you collected in the "Get your SocialID data" step)
 +
  [SocialID setApplicationId:XXX clientSecret:@"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"];
  
... and make it implement the <GPPSignInDelegate> protocol. For example:
+
In the same App Delegate method, setup the Social Login with the user profile fields you want to be retrieved and the Facebook permissions you want to ask to the user. Example initializing the Facebook, Google+ and LinkedIn logins:
  
  @interface SocialIDSampleAppDelegate : UIResponder <UIApplicationDelegate, GPPSignInDelegate>
+
   // Initialize the Social Login
 
+
   [SIDLogin setUserFields:@"display_name,picture_url,current_location,verified_email"];
Add the following code to the (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions method in your app delegate implementation file:
+
 
+
   // Initialize SocialID SDK (use the data you collected in the "Get your SocialID data" step)
+
   [SocialID setApplicationId:XXX secret:@"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"];
+
  [SocialID setMarketingAccountId:XXX secret:@"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"];
+
 
   [SIDFacebook initializeFacebook];
 
   [SIDFacebook initializeFacebook];
 +
  [SIDFacebook setPermissions:@[@"public_profile",@"email",@"user_birthday"]];
 
   [SIDGoogle initializeGoogle];
 
   [SIDGoogle initializeGoogle];
   [SIDGoogle setDelegate:self];
+
   [SIDLinkedin initializeLinkedin];
  
Add the following methods to your app delegate implementation file:
+
Add the following method to your app delegate implementation file:
 
+
  - (void) finishedWithAuth: (GTMOAuth2Authentication *)auth
+
                      error: (NSError *) error {
+
      [SIDGoogle finishedWithAuth:auth error:error];
+
  }
+
  
 
   - (BOOL) application: (UIApplication *)application
 
   - (BOOL) application: (UIApplication *)application
Line 66: Line 54:
 
     sourceApplication: (NSString *)sourceApplication
 
     sourceApplication: (NSString *)sourceApplication
 
             annotation: (id)annotation {
 
             annotation: (id)annotation {
       return [SIDGoogle application:application openURL:url sourceApplication:sourceApplication annotation:annotation];
+
       return [SIDLogin handleOpenURL:url sourceApplication:sourceApplication annotation:annotation];
 
   }
 
   }
  
== Modify Info.plist ==
+
= Modify Info.plist =
 
+
If you followed the first steps correctly, you should already have the following data in your app Info.plist file:
+
 
+
* FacebookAppID
+
* FacebookDisplayName
+
* clientID
+
 
+
You will need to add two more items to make Google+ login work:
+
 
+
* clientSecret: The client secret for your "Client ID for iOS application" (found in APIs & auth -> Credentials)
+
* serverID: The client ID for a "Client ID for web application" entry (found in APIs & auth -> Credentials)
+
 
+
And you will need to add three more items to make LinkedIn login work:
+
 
+
* LinkedinCallbackUrl: the callback url you set up on the LinkedIn oauth1 app
+
* LinkedinAPIKey: the API / consumer key you set up on the LinkedIn oauth1 app
+
* LinkedinAPISecret: the API / consumer secret you set up on the LinkedIn oauth1 app
+
 
+
= New Project =
+
 
+
== Download & unzip the sample project ==
+
 
+
[http://www.example.com Download the project]
+
 
+
== Open the project in XCode ==
+
 
+
Unzip the file, open XCode and use File -> Open to find and open the project's folder.
+
 
+
== Setup FacebookSDK (if you didn't already) ==
+
 
+
Follow the instructions [https://developers.facebook.com/docs/ios/getting-started/ here].
+
 
+
== Setup GoogleSDK (if you didn't already) ==
+
 
+
Follow the instructions [https://developers.google.com/+/mobile/ios/getting-started here]. It is important to follow the instructions to the letter (set up all required frameworks, set -ObjC under "Other Linker Flags", etc.).
+
 
+
== Get your Social-ID data ==
+
 
+
You'll need 4 variables to configure the SDK:
+
 
+
* applicationId: Set up an SocialId LoginApp at: https://app.socialidnow.com/marketing/login/apps. Your key is the id of the app.
+
* applicationSecret: The secret can be found on the Call the API menu - https://app.socialidnow.com/marketing/login/apps/APP_ID/apis.
+
* marketingAccountId: This can be found at: https://app.socialidnow.com/marketing/apis.
+
* marketingAccountSecret: This can be found at: https://app.socialidnow.com/marketing/apis.
+
 
+
== Initialize the SDK ==
+
 
+
Fill in the variables in the following code found in SocialIDSampleAppDelegate.m:
+
 
+
  [SocialID setApplicationId:XXX secret:@"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"];
+
  [SocialID setMarketingAccountId:XXX secret:@"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"];
+
 
+
== Modify Info.plist ==
+
  
If you followed the first steps correctly, you should already have the following data in your app Info.plist file:
+
If you followed the first steps correctly, you should already have the following Facebook data in your app Info.plist file:
  
 
* FacebookAppID
 
* FacebookAppID
 
* FacebookDisplayName
 
* FacebookDisplayName
* clientID
+
* fb{FACEBOOK_APP_ID} in the URL types
  
You will need to add two more items to make Google+ login work:
+
You should also already have your bundle ID as an URL type, that is required by Google+ SDK. You will need to add one more item to make Google+ login work:
  
* clientSecret: The client secret for your "Client ID for iOS application" (found in APIs & auth -> Credentials)
+
* GoogleClientID: The Client ID for your "Client ID for iOS application" (found in APIs & auth -> Credentials)
* serverID: The client ID for a "Client ID for web application" entry (found in APIs & auth -> Credentials)
+
  
And you will need to add three more items to make LinkedIn login work:
+
And you will need to add two more items to make LinkedIn login work:
  
* LinkedinCallbackUrl: the callback url you set up on the LinkedIn oauth1 app
+
* LinkedinAPIKey: the API / consumer key you set up on the LinkedIn OAuth1 app
* LinkedinAPIKey: the API / consumer key you set up on the LinkedIn oauth1 app
+
* LinkedinAPISecret: the API / consumer secret you set up on the LinkedIn OAuth1 app
* LinkedinAPISecret: the API / consumer secret you set up on the LinkedIn oauth1 app
+

Revision as of 13:32, 17 September 2015

Contents

Download the SDK

Extract the zip file's contents and drag & drop the SocialID.framework file to the "Frameworks" folder in your XCode project.

Download the SDK

Setup Facebook iOS SDK

Follow the instructions here if you didn't already.

You need to follow the steps 4 and 5:

The other steps are optional. You can follow them if you want to explore more features from Facebook SDK.

Setup Google iOS SDK

Follow the instructions here if you didn't already. It is important to follow the instructions to the letter (set up all required frameworks, set -ObjC under "Other Linker Flags", etc.).

Get your SocialID Data

You will need 2 variables to configure the SDK:

Setup the Social-ID SDK into your app

Add the following statement to your ViewController:

 #import <SocialID/SocialID.h>

Add the following code to the "(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions" method in your App Delegate implementation file:

 // Initialize SocialID SDK (use the data you collected in the "Get your SocialID data" step)
 [SocialID setApplicationId:XXX clientSecret:@"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"];

In the same App Delegate method, setup the Social Login with the user profile fields you want to be retrieved and the Facebook permissions you want to ask to the user. Example initializing the Facebook, Google+ and LinkedIn logins:

 // Initialize the Social Login
 [SIDLogin setUserFields:@"display_name,picture_url,current_location,verified_email"];
 [SIDFacebook initializeFacebook];
 [SIDFacebook setPermissions:@[@"public_profile",@"email",@"user_birthday"]];
 [SIDGoogle initializeGoogle];
 [SIDLinkedin initializeLinkedin];

Add the following method to your app delegate implementation file:

 - (BOOL) application: (UIApplication *)application
              openURL: (NSURL *)url
    sourceApplication: (NSString *)sourceApplication
           annotation: (id)annotation {
     return [SIDLogin handleOpenURL:url sourceApplication:sourceApplication annotation:annotation];
 }

Modify Info.plist

If you followed the first steps correctly, you should already have the following Facebook data in your app Info.plist file:

  • FacebookAppID
  • FacebookDisplayName
  • fb{FACEBOOK_APP_ID} in the URL types

You should also already have your bundle ID as an URL type, that is required by Google+ SDK. You will need to add one more item to make Google+ login work:

  • GoogleClientID: The Client ID for your "Client ID for iOS application" (found in APIs & auth -> Credentials)

And you will need to add two more items to make LinkedIn login work:

  • LinkedinAPIKey: the API / consumer key you set up on the LinkedIn OAuth1 app
  • LinkedinAPISecret: the API / consumer secret you set up on the LinkedIn OAuth1 app
Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox