Getting started with GetSocial React Native SDK

Welcome to the Getting Started section of the GetSocial documentation. Here you will find guides that describe how to accomplish a specific task with code samples you can re-use in your app.

System Requirements

To use GetSocial SDK your execution and development environment should match the following requirements:

Android

  • Android v4.0.3 (SDK v15) or higher
  • Android Developers Tools (ADT) version 19 or above
  • Google Play Services library v6.1.11 or above (for push notifications)

iOS

  • Xcode 8 or above
  • iOS 8 or higher

Not sure if GetSocial is going to work in your specific configuration? Feel free to reach us via Intercom or email.

Adding GetSocial to Your App

Create App on the Dashboard

To start using GetSocial, you have to create a free account and login to GetSocial Dashboard. Dashboard provides a web interface to manage all GetSocial services.

  1. Login to GetSocial Dashboard.
  2. Open Add new app wizard.
  3. Fill in App name and upload App icon image.
  4. Select React Native platform and Finish the wizard.

Learn more about the products we build at getsocial.im.

Install React Native package

  1. Run npm install getsocial-react-native-sdk --save in your app’s root folder.
  2. Open your app’s package.json file and the following lines to "scripts" section. The script automatically downloads required GetSocial frameworks for iOS.
    1
    2
    3
    4
    5
    "scripts": {
        ...
        "postinstall": "node node_modules/getsocial-react-native-sdk/scripts/download_ios_frameworks.js",
        ...
    }
    
  3. Execute npm install again.
  4. Run react-native link or react-native link getsocial-react-native-sdk to link plugin to your app.

Configure Dependencies (optional)

To obtain more accurate data about installs and make attribution more reliable on Android, GetSocial is using Google Play Install Referrer API. To add library to your project:

  1. Open the Android application project build.gradle.
  2. Add library to the dependencies list:

    1
    2
    3
    4
    dependencies {
        ...
        implementation 'com.android.installreferrer:installreferrer:1.0'
    }
    

    Using Gradle version before 3.0?

    Starting from version 3.0.0 Gradle deprecated compile dependency scope and replaced with implementation. If you are using Gradle version before 3.0.0, replace implementation keyword with compile to avoid build errors.

Enable Supported App Stores on the Dashboard

Next step is to enable Google Play and Apple App Store on the GetSocial Dashboard:

  1. On the App settings section → App information tab.
  2. Enable Google Play store → fill in Package name and Signing-certificate fingerprint fields.

    Create new app on GetSocial Dashboard

    Package name is the applicationId in your app-level build.gradle file.

    Signing-certificate fingerprint is a list of SHA-256 hashes of the certificates you use to sign your application. You have to add fingerprints of all keys you use to sign app. GetSocial Gradle plugin adds a helper task printSigningCertificateSHA256 to print SHA-256 fingerprints for all configured build flavors:

    1
    gradle printSigningCertificateSHA256
    

    Keystore SHA 256 hash

    Using Google Play App Signing?

    If you are using Google Play App Signing you can copy SHA256 from the Play Console. If you’re using a separate Upload certificate, please add his SHA256 to GetSocial Dashboard as well. Learn more in the detailed guide.

  3. Enable Apple App Store → fill in Bundle ID, Team ID and optionally App Store ID fields:

    Create new app on GetSocial Dashboard

    Bundle ID is a part of the iOS App ID. You can find bundle identifier in the Xcode project → General Settings → Identity → Bundle Identifier.

    Team ID is a unique 10-character string generated by Apple that’s assigned to your team. You can find your Team ID using your Apple developer account → Membership.

    App Store ID number can be found in the iTunes store URL as the string of numbers directly after id. For Example, in https://itunes.apple.com/us/app/yourapp/id284709449 the ID is: 284709449.

Configure GetSocial SDK

Android

To start using GetSocial, you have to add and configure GetSocial Gradle Plugin to your Android project. Plugin adds all GetSocial dependencies to the project and configures AndroidManifest.xml.

To add GetSocial Gradle plugin:

  1. Add repository and classpath dependency for the plugin in your top-level build.gradle. This file is for the entire project so it will be used for global project configurations:

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    buildscript {
        repositories {
            ...
            maven {
                url "https://plugins.gradle.org/m2/"
            }
        }
        dependencies {
            ...
            classpath "im.getsocial:plugin:[0,1)"
        }
    }
    
  2. In the Android application project build.gradle (this file is the module build file, so it will be used for specific module level configs) apply im.getsocial plugin after com.android.application plugin:

    1
    2
    apply plugin: 'com.android.application'
    apply plugin: 'im.getsocial' // should be applied after com.android.application plugin
    
  3. In the same build.gradle configure GetSocial plugin with GetSocial App id:

    1
    2
    3
    4
    getsocial {
        appId "put-your-getsocial-app-id-here"
        ...
    }
    

Check the GetSocial Gradle plugin reference for the full list of available configurations.

iOS

To start using GetSocial, you have to add and configure GetSocial installer script to your Xcode project. The script adds GetSocial frameworks to the project and configures app entitlements, plist files, and Xcode project settings.

Alternatively, you can add frameworks and modify all settings manually. Please follow the iOS manual integration guide for details.

To add GetSocial installer script:

  1. In your Xcode project go to Project Settings → select target you want to modify → Build Phases tab.
  2. Create new Run Script phase with the content:

    1
    "$PROJECT_DIR/getsocial.sh" --app-id="your-getsocial-app-id"
    
  3. Move Run Script phase before the Compile Sources phase.

  4. If you are using CocoaPods, please add GetSocial SDK pods to your Podfile manually:

    1
    2
    pod "GetSocial/Core"
    pod "GetSocial/UI" # add this pod only if you plan to use GetSocial UI
    

    And run pod install to update dependencies.

  5. Build your project.

GetSocial Installer script supports multiple configuration parameters, check the iOS Installer Script Reference for the full list of supported parameters.

Project Backups

GetSocial installer script creates a backup of your project.pbxproj file every time it is executed. If something goes wrong, you can always roll back to the previous version.

Source Control Configuration

We suggest adding .backup files under .xcodeproj to ignore list to keep your version control history clean.

Start Using GetSocial

GetSocial UI

At this point, you should be able to start using GetSocial.

GetSocial UI library contains easy to customize views for all GetSocial features, e.g. code below will create and show GetSocial Smart Invites view:

1
2
3
import {GetSocialUI, InvitesView} from 'getsocial-react-native-sdk';
...
GetSocialUI.createInvitesView().show();

After invoking code above, GetSocial Smart Invites view will be shown:

GetSocial Smart Invites View

Why there are only a few apps?

The list of Smart Invites Channels in the view above will contain all social apps that are 1) enabled on the GetSocial Dashboard and 2) installed on the device.

SDK Initialization

GetSocial SDK is auto-initialized, just provide a GetSocial App Id in the Gradle plugin on Android, or as a parameter to the iOS Installer Script on iOS, and we will do the magic.

Manual Initialization

If you want to initialize GetSocial SDK manually, check this topic.

If you want to be notified about initialization complete, you can register a listener, which will be invoked when SDK gets initialized or invoked immediately if it is already initialized:

1
2
3
4
5
import {GetSocial} from 'getsocial-react-native-sdk';
...
GetSocial.whenInitialized(() => {
    // GetSocial SDK is ready to use
});

For instance, you can use whenInitialized to ensure GetSocial SDK is initialized to get referral data on the application start:

1
2
3
4
5
6
7
componentWillMount(){
    GetSocial.whenInitialized(() => {
        GetSocial.getReferralData().then((referralData) => { 
            // process referral data 
        });
    });
}

Demo Application

To showcase all GetSocial SDK features, we have created a simple demo application. Explore it on the GitHub.

Next Steps

Well-done! GetSocial SDK is now set up and ready to rock, check what you can do next:

Give us your feedback! Was this article helpful?

πŸ˜€ πŸ™