Skip to content

Survicate/survicate-unity-sdk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Survicate mobile SDK unity wrapper

Installation

iOS

  • Add content of the iOS directory to your Assets/Plugins/iOS
  • Add SurvicatePluginIOS.cs and file inside your Assets/Plugins
  • Download the latest iOS SDK from here. Copy this file to your xcode project folder.

Inside your exported Xcode project, on Build Phases -> Link Binary With Libraries, add

  • survicate.xcframework

Android

  • Add content of the Android directory to your Assets/Plugins/Android
  • Add SurvicatePluginAndroid.cs file inside your Assets/Plugins
  • Define https://repo.survicate.com Maven repository in the project
  • Add Survicate SDK dependency to your app's build.gradle file.

Configuration

Configuration for Android

  1. Configure your workspace key in AndroidManifest.xml file.
<application
    android:name=".MyApp"
>
    <!-- ... -->
    <meta-data android:name="com.survicate.surveys.workspaceKey" android:value="YOUR_WORKSPACE_KEY"/>
</application>
  1. Define https://repo.survicate.com Maven repository in one of the following ways:
// settingsTemplate.gradle
dependencyResolutionManagement {
    // ...
    repositories {
        // ...
        maven { url 'https://repo.survicate.com' }
    }
}
// mainTemplate.gradle
allprojects {
    repositories {
        // ...
        maven { url 'https://repo.survicate.com' }
    }
}
  1. Add Survicate SDK dependency to your app's build.gradle file.
// mainTemplate.gradle
dependencies {
    // ...
    implementation 'com.survicate:survicate-sdk:latest.release'
}

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.

Initialization

Initialize the SDK in your application using initializeSdk() method. Call this method only once, in the main script of your project.


Usage

On your C# script, import

using Plugins.Survicate;

Survicate.SetWorkspaceKey("your_workspace_key");
Survicate.Initialize();
Survicate.EnterScreen("your_screen_key");
Survicate.LeaveScreen("your_screen_key");
Survicate.InvokeEvent("your_event_name");
Dictionary<string, string> eventProperties = new Dictionary<string, string>();
eventProperties.Add("property1", "value1");
eventProperties.Add("property2", "value2");
Survicate.InvokeEvent("your_event_name", eventProperties);
Survicate.SetUserTrait(new UserTrait("name", "John"));
Survicate.SetUserTrait(new UserTrait("age", 25));
Survicate.SetUserTrait(new UserTrait("count", 0.1));
Survicate.SetUserTrait(new UserTrait("isActive", true));
Survicate.SetUserTrait(new UserTrait("birthDate", DateTime.Now));
Survicate.Reset();
SurvicateEventListener survicateEventListener = new SurvicateEventListener(
    (SurveyDisplayedEvent event) => /* implement action */,
    (QuestionAnsweredEvent event) => /* implement action */,
    (SurveyClosedEvent event) => /* implement action */,
    (SurveyCompletedEvent event) => /* implement action */
);
Survicate.AddSurvicateEventListener(survicateEventListener);
Survicate.RemoveSurvicateEventListener(survicateEventListener);