Skip to content

GetSocial iOS SDK Manual Integration Guide

Basic Setup

Using Cocoapods

CocoaPods is a dependency manager for Swift and Objective-C Cocoa projects. GetSocial SDK is available via CocoaPods.

  1. Follow the official guide or the guide below to set up CocoaPods in your project:
  2. Add the GetSocial SDK pods to your Podfile:

    pod "GetSocial/Core"
    pod "GetSocial/UI"
    

    Add GetSocial/UI dependency only if you plan to use GetSocial UI.

  3. Change the deployment target in the podfile if is different from the one you defined in your project.

  4. From the terminal, install the SDK:

    pod install
    
  5. Make sure that from now on, you open the .xcworkspace instead of the .xcodeproj.

CocoaPods with Dynamic Frameworks

GetSocial SDK shipped as dynamic frameworks. To make sure it properly works, add use_frameworks! to Podfile

Integrating the Dynamic Framework

  1. Download the latest GetSocial frameworks from the Downloads page.
  2. Copy GetSocial.framework and, if you plan to use GetSocial UI, GetSocialUI.framework into your project.
  3. Drag GetSocial.framework and optionally GetSocialUI.framework into the Embedded Binaries section of your target:

    Xcode Target Settings - Adding Embedded Binaries

  4. Download strip_frameworks.sh file from here, and place it under your project’s root folder.

  5. Add a new Run Script phase in your targetโ€™s Build Phases. Paste the following lines in this Run Script Phase’s script text field:

    bash ./strip_frameworks.sh
    
  6. Make sure Run Script Phase is below the Embed Frameworks build phase. You can drag and drop build phases to rearrange them:

    Xcode Target Settings - Setup Run Script Phase

  7. Set Always Embed Swift Standard Libraries to Yes in Build Settings.

Avoid App Store Rejections

If an iOS framework contains a fat binary with the simulator (i386/x86_64) and device (ARM) slices, any application that attempts to embed that framework will be rejected from App Store submission. The script_frameworks.sh script works around an App Store submission bug triggered by universal binaries.

Add Configuration File

The last step before using GetSocial is to add getsocial.json file to your project.

Smart Invites

Setup URL Schemes for Invite Channels

Since iOS 9, Apple requires apps to specify which URL schemes will be used inside the app. The GetSocial SDK uses URL schemes to interact with some of the Invite Channels, therefore you will need to add them to the Info.plist file.

  1. In your project open Info.plist.
  2. Create a new plist item with name LSApplicationQueriesSchemes of Array type and following URL schemes as elements:

    <key>LSApplicationQueriesSchemes</key>
    <array>
        <string>kik-share</string>
        <string>line</string>
        <string>tg</string>
        <string>viber</string>
        <string>whatsapp</string>
    </array>
    
  3. In the editor result should look like:

    Xcode - Info.plist

Setup Url Schemes for iOS 8

Deep linking on iOS 8 works through Url Schemes. You can register an Url Scheme like getsocial:// in your app, and the OS will open your app when the user clicks on a link or is redirected to an URL that starts with that Url Scheme.

To register an Url Scheme in your app, open the .plist file in your project and create an array key called URL types with a single array sub-item called URL Schemes.

Add a single string item inside with this content getsocial-[GETSOCIAL_APP_ID]. You can find the [GETSOCIAL_APP_ID] in the App Settings section of the GetSocial Dashboard.

<key>CFBundleURLTypes</key>
<array>
    <dict>
        <key>CFBundleURLSchemes</key>
        <array>
            <string>getsocial-[GETSOCIAL_APP_ID]</string>
        </array>
    </dict>
</array>

Apple introduced Universal Links on iOS 9 to remove some of the pain points of Url Schemes. Universal Links allows you to use regular URLs instead of the Url Schemes and takes care automatically of the fallback if your app is not installed on the device.

Although Universal Links sound great, their configuration can be a bit painful.

Let us help you through the setup process:

  1. Open your Xcode project.
  2. Enable Associated Domains in your app. In Xcode, go to Capabilities tab → Associated Domains section and copy Smart Invite Link domain from the GetSocial Dashboard.

    Copy Smart Links Domain Configuration

    There are two options:

    • If you are using prefix for gsc.im domain for Invite Links, you have to add following two lines to Associated Domains:

      1
      2
      applinks:[PREFIX].gsc.im
      applinks:[PREFIX]-gsalt.gsc.im
      
    • If you are using custom domain for Invite Links:

      1
      2
      applinks:[YOUR_CUSTOM_DOMAIN]
      applinks:[PREFIX].gsc.im
      

    For instance for our Documentation Demo app we use prefix for gsc.im domain for Invite Links, Associated Domains configuration will be the following:

    Copy domain from GetSocial Dashboard to Xcode

Push Notifications

Enable/Disable GetSocial Notifications on the Client Side

By default on the application start, GetSocial SDK automatically register at push server, and the user will start receiving push notifications.

To prevent this behaviour:

  1. Add pushNotifications.autoRegister property with value false to your getsocial.json file:

    ...
    "pushNotifications": {
        "autoRegister": false,
        ...
    }
    ...
    
  2. To start receiving GetSocial push notifications call:

    GetSocial.registerDevice()
    

To enable push notifications, just remove the pushNotifications.autoRegister property from getsocial.json or set its value to true.

Show Notifications In Foreground

Add pushNotifications.foreground property with value true to your getsocial.json:

...
"pushNotifications": {
    "foreground": true,
    ...
}
...

UI Configuration

Configuration Loading

To load UI Configuration file Resources/getsocial/ui-landscape.json set uiConfig property with value getsocial/ui-landscape.json in your getsocial.json file:

...
"uiConfig" : "getsocial/ui-landscape.json"
...

Give us your feedback! Was this article helpful?

๐Ÿ˜€ ๐Ÿ™