IOS SDK Setup

From Social ID Developers
(Difference between revisions)
Jump to: navigation, search
(Setup FacebookSDK (if you didn't already))
(Setup Sign In with Apple)
 
(30 intermediate revisions by 4 users not shown)
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.
  
[http://dev.socialidnow.com/index.php/iOS_SDK_Download Download the SDK]
+
[[iOS_SDK_Download|Download the SDK]]
  
== Setup FacebookSDK (if you didn't already) ==
+
= SDK Dependencies =
  
Follow the instructions [https://developers.facebook.com/docs/ios/getting-started/ here].
+
{| class="wikitable floatright"
 +
|+ SDK Dependencies by version
 +
! Version
 +
! Facebook
 +
! Google
 +
! Twitter
 +
|-
 +
| [http://dev.socialidnow.com/index.php?title=IOS_SDK_Download 2.0]
 +
| FacebookSDK 3.24.0
 +
| GooglePlus 1.7.1 & GoogleOpenSource 1.7.1
 +
| -
 +
|-
 +
| [http://dev.socialidnow.com/index.php?title=IOS_SDK_Download 2.1]
 +
| Facebook SDK 4.7.0
 +
| GoogleSignIn 2.0
 +
| -
 +
|-
 +
| [http://dev.socialidnow.com/index.php?title=IOS_SDK_Download 3.0]
 +
| Facebook SDK 4.7.0
 +
| GooglePlus 1.7.1 & GoogleOpenSource 1.7.1
 +
| Fabric 1.5.5 & TwitterCore 1.11.4 & TwitterKit 1.11.4
 +
|-
 +
| [http://dev.socialidnow.com/index.php?title=IOS_SDK_Download 3.1]
 +
| Facebook SDK 4.7.0
 +
| GoogleSignIn v3.0.0
 +
| Fabric 1.5.5 & TwitterCore 1.11.4 & TwitterKit 1.11.4
 +
|-
 +
| [http://dev.socialidnow.com/index.php?title=IOS_SDK_Download 3.2]
 +
| Facebook SDK 4.7.0
 +
| GoogleSignIn v3.0.0
 +
| Fabric 1.5.5 & TwitterCore 1.11.4 & TwitterKit 1.11.4
 +
|-
 +
| [http://dev.socialidnow.com/index.php?title=IOS_SDK_Download 3.3]
 +
| Facebook SDK 4.23.0
 +
| GoogleSignIn 4.0.1
 +
| Fabric 1.6.12 & TwitterCore 3.0 & TwitterKit 3.1
 +
|-
 +
| [http://dev.socialidnow.com/index.php?title=IOS_SDK_Download 3.4]
 +
| Facebook SDK 4.40.0
 +
| GoogleSignIn 4.4.0
 +
| TwitterCore 3.2.0 & TwitterKit 3.4.2
 +
|-
 +
| [http://dev.socialidnow.com/index.php?title=IOS_SDK_Download 3.5] (current)
 +
| Facebook SDK 5.4.1
 +
| GoogleSignIn 4.4.0
 +
| TwitterCore 3.2.0 & TwitterKit 3.4.2
 +
|}
  
You need to follow the steps 4 and 5:
+
* iOS: 10.3+
 +
* FacebookSDK.framework (version 4.40.0) [for Facebook login]
 +
* GoogleSignIn (version 4.4.0) [for Google login]
 +
* TwitterCore (version 3.2.0) [for Twitter login]
 +
* TwitterKit (version 3.4.2) [for Twitter login]
 +
* SystemConfiguration.framework
 +
* AuthenticationServices.framework
 +
* UIKit.framework
 +
* Foundation.framework
  
4. [https://developers.facebook.com/docs/ios/getting-started#addSDK Add the SDK to your Xcode Project]
+
The Facebook, Google and Twitter SDKs also have its own dependencies. Follow the next instructions to setup them.
  
5. [https://developers.facebook.com/docs/ios/getting-started#xcode Configure Xcode Project]
+
The current Social-ID SDK was built and tested against the SDK versions listed above. You can also try to use earlier or later dependency versions case your project requires it, the social network SDKs (e.g. Facebook) are compatible in general. Contact us case you have issues with the Social-ID SDK when building your project.
  
The other steps are optional. You can follow them if you want to explore more features from Facebook SDK.
+
= Setup Facebook iOS SDK =
  
== Setup GoogleSDK (if you didn't already) ==
+
Follow the instructions [https://developers.facebook.com/docs/ios/getting-started/ here] (from steps 1 to 3) 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.).
+
You need to follow the steps 1, 2, 3 and 4:
  
== Get your Social-ID data ==
+
* 1. [https://developers.facebook.com/docs/ios/getting-started#settings Configure Facebook App Settings for iOS]
 +
* 2. [https://developers.facebook.com/docs/ios/getting-started#link-sdk Link to the SDK]
 +
* 3. [https://developers.facebook.com/docs/ios/getting-started#xcode Configure Info.plist]
  
You will need 4 variables to configure the SDK:
+
= Setup Google iOS SDK =
  
* applicationId: Set up a Social-Id LoginApp at: https://app.socialidnow.com/marketing/login/apps. Your key is the id of the app.
+
Follow the instructions [https://developers.google.com/identity/sign-in/ios/sdk/ here] if you didn't already.
* 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.
+
  
== Add the SDK to your app ==
+
Step List:
 +
* [https://developers.google.com/identity/sign-in/ios/sdk/#download_the_google_sign-in_sdk Download the Google Sign-In SDK]
 +
* [https://developers.google.com/identity/sign-in/ios/sdk/#add_the_sdk_your_xcode_project Add the SDK your Xcode project]
 +
* [https://developers.google.com/identity/sign-in/ios/sdk/#link_dependent_frameworks_to_your_xcode_project Link dependent frameworks to your Xcode project]
 +
* [https://developers.google.com/identity/sign-in/ios/sdk/#get_an_oauth_client_id Get an OAuth client ID]
 +
* [https://developers.google.com/identity/sign-in/ios/sdk/#add_a_url_scheme_to_your_project Add a URL scheme to your project]
  
Add the following statement to your ViewController:
+
You need to follow all instructions except the last step ([https://developers.google.com/identity/sign-in/ios/sdk/#next_steps "Next Steps"]), as any configuration inside the code is done through the SocialID SDK.
  
  #import <SocialID/SocialID.h>
+
= Setup TwitterKit iOS SDKs =
  
Add the following code to your app delegate header file:
+
The Twitter login is provided by [https://github.com/twitter/twitter-kit-ios TwitterKit for iOS]. Follow the instructions [https://github.com/twitter/twitter-kit-ios/wiki/Installation here] to install the SDKs.
  
  #import <GooglePlus/GooglePlus.h>
+
Step list:
 +
* [https://github.com/twitter/twitter-kit-ios/wiki/Installation#obtain-application-key--secret Obtain Application Key & Secret]
 +
** Add a callback url to the Application's Callback URL list using the following format (see [https://developer.twitter.com/en/docs/basics/apps/guides/callback-urls documentation]):
  
... and make it implement the <GPPSignInDelegate> protocol. For example:
+
  twitterkit-CONSUMERKEY://
  
  @interface SocialIDSampleAppDelegate : UIResponder <UIApplicationDelegate, GPPSignInDelegate>
+
Example:
  
Add the following code to the (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions method in your app delegate implementation file:
+
  twitterkit-128238aKjqlp123AKdasdf://
  
  // Initialize SocialID SDK (use the data you collected in the "Get your SocialID data" step)
+
* Install TwitterKit using [https://github.com/twitter/twitter-kit-ios/wiki/Installation#install-twitter-kit-using-cocoapods Cocoapods], [https://github.com/twitter/twitter-kit-ios/wiki/Installation#install-twitter-kit-using-carthage Carthage] or [https://github.com/twitter/twitter-kit-ios/wiki/Installation#install-twitter-kit-manually manually].
  [SocialID setApplicationId:XXX secret:@"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"];
+
** Ensure to add both TwitterKit and TwitterCore to "Embedded Binaries" in your Xcode project "General" settings, otherwise you can have runtime errors like "Reason: image not found".
  [SocialID setMarketingAccountId:XXX secret:@"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"];
+
* [https://github.com/twitter/twitter-kit-ios/wiki/Installation#configure-infoplist Configure Info.Plist]
  [SIDFacebook initializeFacebook];
+
  [SIDGoogle initializeGoogle];
+
  [SIDGoogle setDelegate:self];
+
  
Add the following methods to your app delegate implementation file:
+
The Social-ID iOS SDK already initializes the TwitterKit when the Twitter login is initialized. However, you will need to configure the TwitterConsumerKey and TwitterConsumerSecret in your app Info.plist file (see the instructions below).
  
   - (void) finishedWithAuth: (GTMOAuth2Authentication *)auth
+
= Setup Sign In with Apple =
                      error: (NSError *) error {
+
 
      [SIDGoogle finishedWithAuth:auth error:error];
+
Apple introduced the brand new "[https://developer.apple.com/sign-in-with-apple/get-started/ Sign In with Apple]" capability for web and apps. If you use any social login in your iOS app you'll need to also add the "Sign In with Apple" option to be in compliance with [https://developer.apple.com/app-store/review/guidelines/#sign-in-with-apple Apple Store Review Guidelines].
  }
+
 
 +
Follow this steps:
 +
 
 +
* Generate App ID and Key following the [[Apple Social App User Guide|configuration guide]]
 +
* [https://help.apple.com/xcode/mac/11.0/#/dev50571b902 Enable the "Sign In with Apple" capability] for your app in Xcode
 +
* Important: this new capability is available only for iOS 13.0+
 +
 
 +
= 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 "application:didFinishLaunchingWithOptions" method in your App Delegate implementation file:
 +
 
 +
    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
 +
       
 +
        // Initialize SocialID SDK (use the data you collected in the "Get your SocialID data" step):
 +
        SocialID setApplicationId:XXX clientSecret:@"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"];
 +
       
 +
        // Initialize application session to access application APIs:
 +
        if (![SIDAppSession isLoggedIn]) {
 +
            [SIDAppSession refreshToken:^(SIDToken *token) {
 +
                // handle success if you want
 +
            } failure:^(NSError *error) {
 +
                // handle failure if you want
 +
            }];
 +
        }
 +
       
 +
        // Initialize social logins, including the scopes you want to ask to the user:
 +
        [SIDFacebook initializeFacebook];
 +
        [SIDFacebook setPermissions:@[ @"public_profile", @"email", @"user_birthday" ]];
 +
        [SIDGoogle initializeGoogle];
 +
        [SIDGoogle setScopes:@[ @"profile", @"email", @"https://www.googleapis.com/auth/user.birthday.read" ]];
 +
        [SIDLinkedin initializeLinkedin];
 +
        [SIDLinkedin setScopes:@[ @"r_emailaddress", @"r_liteprofile" ]];
 +
        [SIDTwitter initializeTwitter];
 +
        [SIDApple initializeProvider];
 +
       
 +
        // Set the user profile fields you want to retrieve when the user logs in;
 +
        [SIDLogin setUserFields:@"display_name,picture_url,current_location,verified_email,picture_urls"];
 +
       
 +
        // Trigger finish launching for login
 +
        [SIDLogin application:application didFinishLaunchingWithOptions:launchOptions];
 +
       
 +
        // your code
 +
     
 +
        return YES;
 +
    }
 +
 
 +
Add the following method to your app delegate implementation file:
  
 +
iOS 4.2–9.0:
 
   - (BOOL) application: (UIApplication *)application
 
   - (BOOL) application: (UIApplication *)application
 
               openURL: (NSURL *)url
 
               openURL: (NSURL *)url
 
     sourceApplication: (NSString *)sourceApplication
 
     sourceApplication: (NSString *)sourceApplication
 
             annotation: (id)annotation {
 
             annotation: (id)annotation {
       return [SIDGoogle application:application openURL:url sourceApplication:sourceApplication annotation:annotation];
+
       return [SIDLogin application:application
 +
                          openURL:url
 +
                sourceApplication:sourceApplication
 +
                        annotation:annotation];
 
   }
 
   }
  
== Modify Info.plist ==
+
iOS 9.0+:
 +
  - (BOOL)application:(UIApplication *)app
 +
              openURL:(NSURL *)url
 +
              options:(NSDictionary<UIApplicationOpenURLOptionsKey, id> *)options {
 +
      return [SIDLogin application:app
 +
                          openURL:url
 +
                          options:options];
 +
  }
 +
 
 +
= 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:
+
For LinkedIn login, you will need to add two more items to make it work:
  
* LinkedinCallbackUrl: the callback url you set up on the LinkedIn oauth1 app
+
* LinkedinAPIKey: the Client ID of your LinkedIn app
* LinkedinAPIKey: the API / consumer key you set up on the LinkedIn oauth1 app
+
* LinkedinAPISecret: the Client Secret of your LinkedIn app
* LinkedinAPISecret: the API / consumer secret you set up on the LinkedIn oauth1 app
+
  
= New Project =
+
For Twitter login, you need to add two more items:
  
== Download & unzip the sample project ==
+
* 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
  
[http://www.example.com Download the project]
+
= Preparing for iOS 9 =
  
== Open the project in XCode ==
+
The iOS 9 requires some changes in app configuration.
  
Unzip the file, open XCode and use File -> Open to find and open the project's folder.
+
== Bitcode Error ==
  
== Setup FacebookSDK (if you didn't already) ==
+
Google+ SDK requires Bitcode to be disabled. You should change the following variable in X-Code:
  
Follow the instructions [https://developers.facebook.com/docs/ios/getting-started/ here].
+
  Project > Build Settings > Build Options > Enable Bitcode = No
  
== Setup GoogleSDK (if you didn't already) ==
+
== Facebook iOS 9 Guide ==
  
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 these steps from Facebook iOS 9 guide:
  
== Get your Social-ID data ==
+
* [https://developers.facebook.com/docs/ios/ios9#whitelist Whitelist Facebook Servers for Network Requests]
 +
* [https://developers.facebook.com/docs/ios/ios9#whitelistapp Whitelist Facebook Apps]
  
You'll need 4 variables to configure the SDK:
+
The Social-ID SDK uses the Facebook 4.7.0, so you need to add the following entries for LSApplicationQueriesSchemes:
  
* applicationId: Set up an SocialId LoginApp at: https://app.socialidnow.com/marketing/login/apps. Your key is the id of the app.
+
  <key>LSApplicationQueriesSchemes</key>
* applicationSecret: The secret can be found on the Call the API menu - https://app.socialidnow.com/marketing/login/apps/APP_ID/apis.
+
  <array>
* marketingAccountId: This can be found at: https://app.socialidnow.com/marketing/apis.
+
        <string>fbapi</string>
* marketingAccountSecret: This can be found at: https://app.socialidnow.com/marketing/apis.
+
        <string>fb-messenger-share-api</string>
 +
        <string>fbauth2</string>
 +
        <string>fbshareextension</string>
 +
  </array>
  
== Initialize the SDK ==
+
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.
  
Fill in the variables in the following code found in SocialIDSampleAppDelegate.m:
+
== Whitelist Google+ Application Schemes ==
  
  [SocialID setApplicationId:XXX secret:@"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"];
+
Add the following entries for LSApplicationQueriesSchemes in your app Info.plist file:
  [SocialID setMarketingAccountId:XXX secret:@"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"];
+
  
== Modify Info.plist ==
+
  <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>
  
If you followed the first steps correctly, you should already have the following data in your app Info.plist file:
+
== Whitelist Twitter Servers for Network Requests ==
  
* FacebookAppID
+
Add the following entries for NSAppTransportSecurity in your app Info.plist file:
* FacebookDisplayName
+
 
* clientID
+
  <key>NSAppTransportSecurity</key>
 +
  <dict>
 +
    <key>NSExceptionDomains</key>
 +
    <dict>
 +
        <key>twimg.com</key>
 +
        <dict>
 +
            <key>NSIncludesSubdomains</key>
 +
            <true/>               
 +
            <key>NSThirdPartyExceptionRequiresForwardSecrecy</key>
 +
            <false/>
 +
        </dict>
 +
    </dict>
 +
  </dict>
 +
 
 +
= Known Issues =
 +
 
 +
=== Unsupported Architectures ===
  
You will need to add two more items to make Google+ login work:
+
The TwitterCore and TwitterKit frameworks contain unsupported architectures (x86_64, i386). When you build your app to Beta Testing or Apple Store you may face the following issues (example using [https://fastlane.tools/ fastlane]):
  
* clientSecret: The client secret for your "Client ID for iOS application" (found in APIs & auth -> Credentials)
+
  ERROR ITMS-90087: "Unsupported Architectures. The executable for SocialID Toolbox.app/Frameworks/TwitterCore.framework contains unsupported architectures '[x86_64, i386]'."
* serverID: The client ID for a "Client ID for web application" entry (found in APIs & auth -> Credentials)
+
  ERROR ITMS-90087: "Unsupported Architectures. The executable for SocialID Toolbox.app/Frameworks/TwitterKit.framework contains unsupported architectures '[x86_64, i386]'."
  
And you will need to add three more items to make LinkedIn login work:
+
To fix this issue you can run a script in the Build Phase to [https://stackoverflow.com/questions/30547283/submit-to-app-store-issues-unsupported-architecture-x86 extract these unsupported architectures]:
  
* LinkedinCallbackUrl: the callback url you set up on the LinkedIn oauth1 app
+
  APP_PATH="${TARGET_BUILD_DIR}/${WRAPPER_NAME}"
* 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
+
  # This script loops through the frameworks embedded in the application and
 +
  # removes unused architectures.
 +
  find "$APP_PATH" -name '*.framework' -type d | while read -r FRAMEWORK
 +
  do
 +
      FRAMEWORK_EXECUTABLE_NAME=$(defaults read "$FRAMEWORK/Info.plist" CFBundleExecutable)
 +
      FRAMEWORK_EXECUTABLE_PATH="$FRAMEWORK/$FRAMEWORK_EXECUTABLE_NAME"
 +
      echo "Executable is $FRAMEWORK_EXECUTABLE_PATH"
 +
     
 +
      EXTRACTED_ARCHS=()
 +
     
 +
      for ARCH in $ARCHS
 +
      do
 +
          echo "Extracting $ARCH from $FRAMEWORK_EXECUTABLE_NAME"
 +
          lipo -extract "$ARCH" "$FRAMEWORK_EXECUTABLE_PATH" -o "$FRAMEWORK_EXECUTABLE_PATH-$ARCH"
 +
          EXTRACTED_ARCHS+=("$FRAMEWORK_EXECUTABLE_PATH-$ARCH")
 +
      done
 +
     
 +
      echo "Merging extracted architectures: ${ARCHS}"
 +
      lipo -o "$FRAMEWORK_EXECUTABLE_PATH-merged" -create "${EXTRACTED_ARCHS[@]}"
 +
      rm "${EXTRACTED_ARCHS[@]}"
 +
     
 +
      echo "Replacing original executable with thinned version"
 +
      rm "$FRAMEWORK_EXECUTABLE_PATH"
 +
      mv "$FRAMEWORK_EXECUTABLE_PATH-merged" "$FRAMEWORK_EXECUTABLE_PATH"
 +
     
 +
  done

Latest revision as of 14:52, 2 March 2020

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

SDK Dependencies

SDK Dependencies by version
Version Facebook Google Twitter
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 1.5.5 & TwitterCore 1.11.4 & TwitterKit 1.11.4
3.1 Facebook SDK 4.7.0 GoogleSignIn v3.0.0 Fabric 1.5.5 & TwitterCore 1.11.4 & TwitterKit 1.11.4
3.2 Facebook SDK 4.7.0 GoogleSignIn v3.0.0 Fabric 1.5.5 & TwitterCore 1.11.4 & TwitterKit 1.11.4
3.3 Facebook SDK 4.23.0 GoogleSignIn 4.0.1 Fabric 1.6.12 & TwitterCore 3.0 & TwitterKit 3.1
3.4 Facebook SDK 4.40.0 GoogleSignIn 4.4.0 TwitterCore 3.2.0 & TwitterKit 3.4.2
3.5 (current) Facebook SDK 5.4.1 GoogleSignIn 4.4.0 TwitterCore 3.2.0 & TwitterKit 3.4.2
  • iOS: 10.3+
  • FacebookSDK.framework (version 4.40.0) [for Facebook login]
  • GoogleSignIn (version 4.4.0) [for Google login]
  • TwitterCore (version 3.2.0) [for Twitter login]
  • TwitterKit (version 3.4.2) [for Twitter login]
  • SystemConfiguration.framework
  • AuthenticationServices.framework
  • UIKit.framework
  • Foundation.framework

The Facebook, Google and Twitter SDKs also have its own dependencies. Follow the next instructions to setup them.

The current Social-ID SDK was built and tested against the SDK versions listed above. You can also try to use earlier or later dependency versions case your project requires it, the social network SDKs (e.g. Facebook) are compatible in general. Contact us case you have issues with the Social-ID SDK when building your project.

Setup Facebook iOS SDK

Follow the instructions here (from steps 1 to 3) if you didn't already.

You need to follow the steps 1, 2, 3 and 4:

Setup Google iOS SDK

Follow the instructions here if you didn't already.

Step List:

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 TwitterKit iOS SDKs

The Twitter login is provided by TwitterKit for iOS. Follow the instructions here to install the SDKs.

Step list:

 twitterkit-CONSUMERKEY://

Example:

 twitterkit-128238aKjqlp123AKdasdf://
  • Install TwitterKit using Cocoapods, Carthage or manually.
    • Ensure to add both TwitterKit and TwitterCore to "Embedded Binaries" in your Xcode project "General" settings, otherwise you can have runtime errors like "Reason: image not found".
  • Configure Info.Plist

The Social-ID iOS SDK already initializes the TwitterKit when the Twitter login is initialized. However, you will need to configure the TwitterConsumerKey and TwitterConsumerSecret in your app Info.plist file (see the instructions below).

Setup Sign In with Apple

Apple introduced the brand new "Sign In with Apple" capability for web and apps. If you use any social login in your iOS app you'll need to also add the "Sign In with Apple" option to be in compliance with Apple Store Review Guidelines.

Follow this steps:

Get your SocialID Data

You will need 2 variables to configure the Social-ID SDK:

Setup the Social-ID SDK

Add the following statement to your ViewController:

 #import <SocialID/SocialID.h>

Add the following code to the "application:didFinishLaunchingWithOptions" method in your App Delegate implementation file:

   - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
       
       // Initialize SocialID SDK (use the data you collected in the "Get your SocialID data" step):
       SocialID setApplicationId:XXX clientSecret:@"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"];
       
       // Initialize application session to access application APIs:
       if (![SIDAppSession isLoggedIn]) {
           [SIDAppSession refreshToken:^(SIDToken *token) {
               // handle success if you want
           } failure:^(NSError *error) {
               // handle failure if you want
           }];
       }
       
       // Initialize social logins, including the scopes you want to ask to the user:
       [SIDFacebook initializeFacebook];
       [SIDFacebook setPermissions:@[ @"public_profile", @"email", @"user_birthday" ]];
       [SIDGoogle initializeGoogle];
       [SIDGoogle setScopes:@[ @"profile", @"email", @"https://www.googleapis.com/auth/user.birthday.read" ]];
       [SIDLinkedin initializeLinkedin];
       [SIDLinkedin setScopes:@[ @"r_emailaddress", @"r_liteprofile" ]];
       [SIDTwitter initializeTwitter];
       [SIDApple initializeProvider];
       
       // Set the user profile fields you want to retrieve when the user logs in;
       [SIDLogin setUserFields:@"display_name,picture_url,current_location,verified_email,picture_urls"];
       
       // Trigger finish launching for login
       [SIDLogin application:application didFinishLaunchingWithOptions:launchOptions];
       
       // your code
      
       return YES;
   }

Add the following method to your app delegate implementation file:

iOS 4.2–9.0:

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

iOS 9.0+:

 - (BOOL)application:(UIApplication *)app
             openURL:(NSURL *)url
             options:(NSDictionary<UIApplicationOpenURLOptionsKey, id> *)options {
     return [SIDLogin application:app
                          openURL:url
                          options:options];
 }

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 Client ID of your LinkedIn app
  • LinkedinAPISecret: the Client Secret of your LinkedIn app

For Twitter login, 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-share-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>

Known Issues

Unsupported Architectures

The TwitterCore and TwitterKit frameworks contain unsupported architectures (x86_64, i386). When you build your app to Beta Testing or Apple Store you may face the following issues (example using fastlane):

 ERROR ITMS-90087: "Unsupported Architectures. The executable for SocialID Toolbox.app/Frameworks/TwitterCore.framework contains unsupported architectures '[x86_64, i386]'."
 ERROR ITMS-90087: "Unsupported Architectures. The executable for SocialID Toolbox.app/Frameworks/TwitterKit.framework contains unsupported architectures '[x86_64, i386]'."

To fix this issue you can run a script in the Build Phase to extract these unsupported architectures:

 APP_PATH="${TARGET_BUILD_DIR}/${WRAPPER_NAME}"
 
 # This script loops through the frameworks embedded in the application and
 # removes unused architectures.
 find "$APP_PATH" -name '*.framework' -type d | while read -r FRAMEWORK
 do
     FRAMEWORK_EXECUTABLE_NAME=$(defaults read "$FRAMEWORK/Info.plist" CFBundleExecutable)
     FRAMEWORK_EXECUTABLE_PATH="$FRAMEWORK/$FRAMEWORK_EXECUTABLE_NAME"
     echo "Executable is $FRAMEWORK_EXECUTABLE_PATH"
     
     EXTRACTED_ARCHS=()
     
     for ARCH in $ARCHS
     do
         echo "Extracting $ARCH from $FRAMEWORK_EXECUTABLE_NAME"
         lipo -extract "$ARCH" "$FRAMEWORK_EXECUTABLE_PATH" -o "$FRAMEWORK_EXECUTABLE_PATH-$ARCH"
         EXTRACTED_ARCHS+=("$FRAMEWORK_EXECUTABLE_PATH-$ARCH")
     done
     
     echo "Merging extracted architectures: ${ARCHS}"
     lipo -o "$FRAMEWORK_EXECUTABLE_PATH-merged" -create "${EXTRACTED_ARCHS[@]}"
     rm "${EXTRACTED_ARCHS[@]}"
     
     echo "Replacing original executable with thinned version"
     rm "$FRAMEWORK_EXECUTABLE_PATH"
     mv "$FRAMEWORK_EXECUTABLE_PATH-merged" "$FRAMEWORK_EXECUTABLE_PATH"
     
 done
Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox