Installation
Table of contents
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
Maven
We recommend using maven repository to get Survicate SDK.
- Define
https://repo.survicate.com
maven repository in project’sbuild.gradle
file. Make sure that repository is defined inallprojects
section, notbuildscript
. - Add
com.survicate:survicate-sdk:1.+
dependency to your app’sbuild.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.
- Download Survicate for Android
- Copy
Survicate.aar
toapp/libs
directory of your project. - 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
- Configure your workspace key in
AndroidManifest.xml
file. Create meta-data:com.survicate.surveys.workspaceKey
. - 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 inAndroidManifest.xml
.
AndroidManifest.xml
<application
android:name=".MyApp"
>
<!-- ... -->
<meta-data android:name="com.survicate.surveys.workspaceKey" android:value="YOUR_WORKSPACE_KEY"/>
</application>
Application class
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 *
-keep public class com.survicate.surveys.entities.**
-keep public class com.survicate.surveys.infrastructure.network.**
-keep public class com.survicate.surveys.infrastructure.serialization.**
Also, make sure that you have latest Gradle version with R8 enabled in gradle.properties
file:
android.enableR8=true
iOS
CocoaPods
We recommend using CocoaPods to get Survicate SDK.
- Define pod in your
Podfile
and runpod install
.
Podfile
platform :ios, '10.0'
target 'MyApp' do
pod 'Survicate'
end
Manual installation
Another way is to install it manually.
-
Drag Survicate.framework into your project. Make sure “Copy items if needed” is selected and click Finish.
-
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
- Add workspace key to your
Info.plist
file.- Create
Survicate
Dictionary. - Define
WorkspaceKey
String inSurvicate
Dictionary. YourInfo.plist
file should looks like this:
- Create
- 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
// ...
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
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
- Configure your workspace key in
AndroidManifest.xml
file. - Add Survicate maven repository to your project
build.gradle
located underandroid
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
- Add workspace key to your
Info.plist
file.- Create
Survicate
Dictionary. - Define
WorkspaceKey
String inSurvicate
Dictionary. YourInfo.plist
file should looks like this:
- Create
- Run
pod update
in yourios
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();