Link Search Menu Expand Document

Installation

Table of contents

  1. Android
  2. iOS
  3. React Native

Mobile SDK works on:

  • Android at least on version 4.4
  • iOS at least on version 10

To use this SDK, you need an account at survicate.com. Sign up for free and find your workspace key in Tracking Code section.


Android

Platform Maven

Maven

We recommend using maven repository to get Survicate SDK.

  1. Define https://repo.survicate.com maven repository in project’s build.gradle file. Make sure that repository is defined in allprojects section, not buildscript.
  2. Add com.survicate:survicate-sdk:1.+ dependency to your app’s build.gradle file.

Project’s build.gradle

allprojects {
    repositories {
        // ...
        maven { url 'https://repo.survicate.com' }
    }
}

App’s build.gradle for Maven installation

dependencies {
    // ...
    implementation 'com.survicate:survicate-sdk:1.+'
}

Manual installation

Another way is to install it manually.

  1. Download Survicate for Android
  2. Copy Survicate.aar to app/libs directory of your project.
  3. Add dependencies for manual installation to your app’s build.gradle file.

App’s build.gradle for manual installation

dependencies {
    // ...
    implementation files('libs/Survicate.aar')
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support:cardview-v7:28.0.0'
    implementation 'com.android.support:recyclerview-v7:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    implementation 'com.squareup.moshi:moshi:1.8.0'
    implementation 'com.android.support:transition:28.0.0'
}

Note: Keep in mind that with updating version by manual installation you need to update SDK dependencies versions too.

Configuration

  1. Configure your workspace key in AndroidManifest.xml file. Create meta-data: com.survicate.surveys.workspaceKey.
  2. Initialize the SDK in your application class using init() method. If your project don’t have custom application class yet, you’ll need to create one. Make sure that your custom application class is defined in AndroidManifest.xml.

AndroidManifest.xml

<application
    android:name=".MyApp"
>
    <!-- ... -->
    <meta-data android:name="com.survicate.surveys.workspaceKey" android:value="YOUR_WORKSPACE_KEY"/>
</application>

Application class

Kotlin Java

import android.app.Application
import com.survicate.surveys.Survicate

class MyApp : Application() {
    override fun onCreate() {
        super.onCreate()
        Survicate.init(this)
    }
}   
import android.app.Application;
import com.survicate.surveys.Survicate;

public class MyApp extends Application {
  @Override public void onCreate() {
    super.onCreate();
    Survicate.init(this);
  }
}   

Note: For production environment, it is a good practice to define specific SDK version. Just replace last part of dependency, 1.+, with version you want to use.

ProGuard (optional)

If your application uses ProGuard, add the following rule to your proguard-rules.pro file:

-keep @com.squareup.moshi.JsonQualifier class *

Also, make sure that you have latest Gradle version with R8 enabled in gradle.properties file:

android.enableR8=true


iOS

Platform Cocoapods

CocoaPods

We recommend using CocoaPods to get Survicate SDK.

  1. Define pod in your Podfile and run pod install.

Use latest SDK version for Swift 5.2.

For Swift 5.3, use 1.4.1 version and define podspec: pod 'Survicate', :podspec => 'https://repo.survicate.com/ios/1.4.1_Swift5.3/Survicate.podspec'

Podfile

platform :ios, '10.0'

target 'MyApp' do
    pod 'Survicate'
end    

Manual installation

Another way is to install it manually.

  1. Download Survicate for iOS and extract the zip.

  2. Drag Survicate.framework into your project. Make sure “Copy items if needed” is selected and click Finish.

  3. In the target settings for your app, set the Survicate.framework to “Embed & Sign”. This can be found in the “Frameworks, Libraries, and Embedded Content” section of the “General” tab.

Configuration

  1. Add workspace key to your Info.plist file.
    • Create Survicate Dictionary.
    • Define WorkspaceKey String in Survicate Dictionary. Your Info.plist file should looks like this: Info.plist example
  2. Initialize the SDK in your AppDelegate class using initialize method.

Make sure that import Survicate line exists in all classes where you call SDK methods.

AppDelegate class

Swift Objective-C

// ...
import Survicate

class AppDelegate: UIResponder, UIApplicationDelegate {
    // ...
    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
        Survicate.shared.initialize()
        return true
    }
}
// ...
@import Survicate;

@implementation AppDelegate
// ...
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    [[Survicate shared] initialize];
    return YES;
}
@end

React Native

npm version

Mobile SDK is compatible with React Native apps. Please use these React Native bindings to install Mobile SDK in your app.

To install it run: npm install @survicate/react-native-survicate --save

To create linking for iOS and Android in your react native app run react-native link @survicate/react-native-survicate

Note: Our bindings are compatible with auto linking feature introduced in React Native 0.60, so there is no need to run this command on 0.60 and newer versions.

Configuration for Android

  1. Configure your workspace key in AndroidManifest.xml file.
  2. Add Survicate maven repository to your project build.gradle located under android directory.

Project’s build.gradle

allprojects {
    repositories {
        // ...
        maven { url 'https://repo.survicate.com' }
    }
}

AndroidManifest.xml

<application
    android:name=".MyApp"
>
    <!-- ... -->
    <meta-data android:name="com.survicate.surveys.workspaceKey" android:value="YOUR_WORKSPACE_KEY"/>
</application>

Configuration for iOS

  1. Add workspace key to your Info.plist file.
    • Create Survicate Dictionary.
    • Define WorkspaceKey String in Survicate Dictionary. Your Info.plist file should looks like this: Info.plist example
  2. Run pod update in your ios directory.

React Native bindings usage

import Survicate from '@survicate/react-native-survicate';
// ...
Survicate.initialize();
Survicate.invokeEvent("eventName");
Survicate.enterScreen("screenName");
Survicate.leaveScreen("screenName");
Survicate.setUserId("screenName");
Survicate.setUserTrait("traitName", "traitValue");
Survicate.reset();

Setup →


👋 If you bump into any problems or need more support, just start a conversation using Intercom in the bottom-right corner and you will be immediately routed to our Customer Support Engineers.