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.
- Follow the official guide or the guide below to set up CocoaPods in your project:
-
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. -
Change the deployment target in the podfile if is different from the one you defined in your project.
-
From the terminal, install the SDK:
pod install
-
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¶
- Download the latest GetSocial frameworks from the Downloads page.
- Copy
GetSocial.framework
and, if you plan to use GetSocial UI,GetSocialUI.framework
into your project. -
Drag
GetSocial.framework
and optionallyGetSocialUI.framework
into the Embedded Binaries section of your target: -
Download
strip_frameworks.sh
file from here, and place it under your project’s root folder. -
Add a new
Run Script
phase in your targetโsBuild Phases
. Paste the following lines in this Run Script Phase’s script text field:bash ./strip_frameworks.sh
-
Make sure
Run Script Phase
is below theEmbed Frameworks
build phase. You can drag and drop build phases to rearrange them: -
Set
Always Embed Swift Standard Libraries
toYes
inBuild 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.
- In your project open
Info.plist
. -
Create a new plist item with name
LSApplicationQueriesSchemes
ofArray
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>
-
In the editor result should look like:
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>
Setup Universal Links for iOS 9+¶
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:
- Open your Xcode project.
-
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.
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: -
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:
-
Add
pushNotifications.autoRegister
property with valuefalse
to yourgetsocial.json
file:... "pushNotifications": { "autoRegister": false, ... } ...
-
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"
...