IOS SDK Setup
Ramon.maciel (Talk | contribs) |
(→Download the SDK) |
||
Line 3: | Line 3: | ||
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. | ||
− | [ | + | [[iOS_SDK_Download|Download the SDK]] |
= SDK Dependencies = | = SDK Dependencies = |
Revision as of 16:29, 3 August 2017
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
Version | |||
---|---|---|---|
2.0 | FacebookSDK 3.24.0 | GooglePlus 1.7.1 & GoogleOpenSource 1.7.1 | - |
2.1 | Facebook SDK 4.7.0 | GoogleSignIn 2.0 | - |
3.0 | Facebook SDK 4.7.0 | GooglePlus 1.7.1 & GoogleOpenSource 1.7.1 | Fabric 2.0.2 & TwitterCore 1.11.4 & TwitterKit 1.11.4 |
3.1 (current) | Facebook SDK 4.7.0 | GoogleSignIn 3.0 | Fabric 2.0.2 & TwitterCore 1.11.4 & TwitterKit 1.11.4 |
- FacebookSDK.framework (version 4.7.0) [for Facebook login]
- GoogleSignIn (version 3.0.0) [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 instructions except the last step ("Next Steps"), as any configuration inside the code is done through the SocialID SDK.
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
Preparing for iOS 9
The iOS 9 requires some changes in app configuration.
Bitcode Error
Google+ SDK requires Bitcode to be disabled. You should change the following variable in X-Code:
Project > Build Settings > Build Options > Enable Bitcode = No
Facebook iOS 9 Guide
Follow these steps from Facebook iOS 9 guide:
The Social-ID SDK uses the Facebook 4.7.0, so you need to add the following entries for LSApplicationQueriesSchemes:
<key>LSApplicationQueriesSchemes</key> <array> <string>fbapi</string> <string>fb-messenger-api</string> <string>fbauth2</string> <string>fbshareextension</string> </array>
Also, the new Facebook SDK login behavior prioritizes the login via SafariViewController instead of the login via Facebook native app. For more information see https://developers.facebook.com/bugs/786729821439894/?search_id.
Whitelist Google+ Application Schemes
Add the following entries for LSApplicationQueriesSchemes in your app Info.plist file:
<key>LSApplicationQueriesSchemes</key> <array> <string>[APP BUNDLE ID]</string> <string>com.google.gppconsent</string> <string>gplus</string> <string>com-google-gidconsent-google</string> <string>com-google-gidconsent-youtube</string> <string>com-google-gidconsent</string> <string>com.google.gppconsent.2.4.1</string> <string>com.google.gppconsent.2.4.0</string> <string>googlechrome</string> <string>googlechrome-x-callback</string> </array>
Whitelist Twitter Servers for Network Requests
Add the following entries for NSAppTransportSecurity in your app Info.plist file:
<key>NSAppTransportSecurity</key> <dict> <key>NSExceptionDomains</key> <dict> <key>twimg.com</key> <dict> <key>NSIncludesSubdomains</key> <true/> <key>NSThirdPartyExceptionRequiresForwardSecrecy</key> <false/> </dict> </dict> </dict>