IOS SDK Setup
Renato.neves (Talk | contribs) |
Renato.neves (Talk | contribs) |
||
Line 7: | Line 7: | ||
SDK dependencies: | SDK dependencies: | ||
− | * FacebookSDK.framework (version | + | * FacebookSDK.framework (version 4.7.0) [for Facebook login] |
− | * GooglePlus.framework (version 1.7.1) | + | * GooglePlus.framework (version 1.7.1) [for Google+ login] |
− | * GoogleOpenSource.framework (version 1.7.1) | + | * GoogleOpenSource.framework (version 1.7.1) [for Google+ login] |
+ | * Fabric (version 2.0.2) [for Twitter login] | ||
+ | * TwitterCore (version 1.11.4) [for Twitter login] | ||
+ | * TwitterKit (version 1.11.4) [for Twitter login] | ||
* SystemConfiguration.framework | * SystemConfiguration.framework | ||
* UIKit.framework | * UIKit.framework | ||
* Foundation.framework | * Foundation.framework | ||
− | The Facebook | + | The Facebook, Google and Twitter SDKs also have its own dependencies. Follow the next instructions to setup them. |
= Setup Facebook iOS SDK = | = Setup Facebook iOS SDK = | ||
Line 36: | Line 39: | ||
* 2. [https://developers.google.com/+/mobile/ios/getting-started#step_2_initialize_the_google_client Initialize the Google+ Client], adding the ObjC linker flag to the app target's build settings | * 2. [https://developers.google.com/+/mobile/ios/getting-started#step_2_initialize_the_google_client Initialize the Google+ Client], adding the ObjC linker flag to the app target's build settings | ||
* 3. [https://developers.google.com/+/mobile/ios/getting-started#step_3_add_a_url_type Add a URL type] | * 3. [https://developers.google.com/+/mobile/ios/getting-started#step_3_add_a_url_type Add a URL type] | ||
+ | |||
+ | = Setup Fabric/TwitterKit iOS SDKs = | ||
+ | |||
+ | The Twitter login is provided by Fabric and TwitterKit SDKs. You need to install the Fabric app and follow the instructions: | ||
+ | |||
+ | * Fabric: [https://docs.fabric.io/ios/fabric/getting-started.html Fabric - Getting Started] | ||
+ | * TwitterKit: [https://docs.fabric.io/ios/twitter/twitterkit-setup.html Twitter Kit Setup] | ||
+ | |||
+ | The Social-ID iOS SDK already adds the TwitterKit setup code when the Twitter login is initialized, so you don't need to add this code in your project: | ||
+ | |||
+ | // Objective-C | ||
+ | [[Twitter sharedInstance] startWithConsumerKey:@"your_key" consumerSecret:@"your_secret"]; | ||
+ | [Fabric with:@[[Twitter sharedInstance]]]; | ||
+ | |||
+ | However, you will need to configure the TwitterConsumerKey and TwitterConsumerSecret in your app Info.plist file (see the instructions below). | ||
= Get your SocialID Data = | = Get your SocialID Data = | ||
− | You will need 2 variables to configure the SDK: | + | You will need 2 variables to configure the Social-ID 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. | ||
* applicationClientSecret: The API client 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. | ||
− | = Setup the Social-ID SDK | + | = Setup the Social-ID SDK = |
Add the following statement to your ViewController: | Add the following statement to your ViewController: | ||
Line 58: | Line 76: | ||
// Initialize the Social Login | // Initialize the Social Login | ||
− | |||
[SIDFacebook initializeFacebook]; | [SIDFacebook initializeFacebook]; | ||
[SIDFacebook setPermissions:@[@"public_profile",@"email",@"user_birthday"]]; | [SIDFacebook setPermissions:@[@"public_profile",@"email",@"user_birthday"]]; | ||
[SIDGoogle initializeGoogle]; | [SIDGoogle initializeGoogle]; | ||
[SIDLinkedin initializeLinkedin]; | [SIDLinkedin initializeLinkedin]; | ||
+ | [SIDTwitter initializeTwitter]; | ||
+ | [SIDLogin setUserFields:@"display_name,picture_url,current_location,verified_email"]; | ||
+ | [SIDLogin application:application didFinishLaunchingWithOptions:launchOptions]; | ||
Add the following method to your app delegate implementation file: | Add the following method to your app delegate implementation file: | ||
Line 70: | Line 90: | ||
sourceApplication: (NSString *)sourceApplication | sourceApplication: (NSString *)sourceApplication | ||
annotation: (id)annotation { | annotation: (id)annotation { | ||
− | return [SIDLogin | + | return [SIDLogin application:application |
+ | openURL:url | ||
+ | sourceApplication:sourceApplication | ||
+ | annotation:annotation]; | ||
} | } | ||
Line 85: | Line 108: | ||
* GoogleClientID: The Client ID 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) | ||
− | + | For LinkedIn login, you will need to add two more items to make it work: | |
* 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 | ||
+ | |||
+ | For Twitter login, you should already have the Fabric APIKey. You need to add two more items: | ||
+ | |||
+ | * TwitterConsumerKey: the API / consumer key you set up on the Twitter OAuth1 app | ||
+ | * TwitterConsumerSecret: the API / consumer secret you set up on the Twitter OAuth1 app |
Revision as of 23:46, 15 October 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.
SDK dependencies:
- FacebookSDK.framework (version 4.7.0) [for Facebook login]
- GooglePlus.framework (version 1.7.1) [for Google+ login]
- GoogleOpenSource.framework (version 1.7.1) [for Google+ login]
- Fabric (version 2.0.2) [for Twitter login]
- TwitterCore (version 1.11.4) [for Twitter login]
- TwitterKit (version 1.11.4) [for Twitter login]
- SystemConfiguration.framework
- UIKit.framework
- Foundation.framework
The Facebook, Google and Twitter SDKs also have its own dependencies. Follow the next instructions to setup them.
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.
You need to follow all steps:
- 1. Creating the Google Developers Console project
- 2. Initialize the Google+ Client, adding the ObjC linker flag to the app target's build settings
- 3. Add a URL type
Setup Fabric/TwitterKit iOS SDKs
The Twitter login is provided by Fabric and TwitterKit SDKs. You need to install the Fabric app and follow the instructions:
- Fabric: Fabric - Getting Started
- TwitterKit: Twitter Kit Setup
The Social-ID iOS SDK already adds the TwitterKit setup code when the Twitter login is initialized, so you don't need to add this code in your project:
// Objective-C [[Twitter sharedInstance] startWithConsumerKey:@"your_key" consumerSecret:@"your_secret"]; [Fabric with:@Twitter sharedInstance];
However, you will need to configure the TwitterConsumerKey and TwitterConsumerSecret in your app Info.plist file (see the instructions below).
Get your SocialID Data
You will need 2 variables to configure the Social-ID SDK:
- applicationId: Set up a Social-Id LoginApp at: https://app.socialidnow.com/marketing/login/apps. Your key is the id of the app.
- applicationClientSecret: The API client secret can be found on the Call the API menu - https://app.socialidnow.com/marketing/login/apps/APP_ID/apis.
Setup the Social-ID SDK
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 [SIDFacebook initializeFacebook]; [SIDFacebook setPermissions:@[@"public_profile",@"email",@"user_birthday"]]; [SIDGoogle initializeGoogle]; [SIDLinkedin initializeLinkedin]; [SIDTwitter initializeTwitter]; [SIDLogin setUserFields:@"display_name,picture_url,current_location,verified_email"]; [SIDLogin application:application didFinishLaunchingWithOptions:launchOptions];
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 application:application openURL: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)
For LinkedIn login, you will need to add two more items to make it 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
For Twitter login, you should already have the Fabric APIKey. You need to add two more items:
- TwitterConsumerKey: the API / consumer key you set up on the Twitter OAuth1 app
- TwitterConsumerSecret: the API / consumer secret you set up on the Twitter OAuth1 app