Link Search Menu Expand Document

Survicate React Native SDK

npm

Table of contents

  1. Installation
  2. Configuration
    1. Configuration for Android
    2. Configuration for iOS
  3. Using the Survicate SDK
    1. Targeting a survey by screen name
    2. Events-based survey targeting
    3. Passing user attributes
    4. Reseting user data for testing purposes
  4. Changelog

Installation

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

To install 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 the Autolinking feature introduced in React Native 0.60, so there is no need to run this command on 0.60 and newer versions.


Configuration

Configuration for Android

  1. Configure your workspace key in AndroidManifest.xml file.
  2. Add the 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.

Using the Survicate SDK

Survicate allows you to launch precisely targeted surveys inside your app. In the Survicate Panel, you can set conditions that need to be met for the surveys to appear. Users matching conditions defined in the Survicate panel will see the survey automatically. Here’s a list of conditions you can use to target your surveys:

  • Name of the screen that a user currently sees
  • Any application event
  • User attributes and identities
  • Language of the device
  • Operating system

Make sure to list all the screens and events described in your application. Once you got this covered, you or any person responsible for creating and managing surveys will be able to trigger surveys from the Survicate panel with no need for you to update the application.

Targeting a survey by screen name

A survey can appear when a user is viewing a specific screen. For example, a survey can be triggered to show up on the application’s home screen after a user spends more than ten seconds there. To set it up, you need to send information to Survicate about the user entering and leaving a screen.

// ...
Survicate.enterScreen("screenName");
// ...
Survicate.leaveScreen("screenName");

Screen name is case sensitive. If there’s any discrepancy between what’s declared in the ‘Screens’ tab of the Target section in the Survicate panel and the application code, the survey will not appear.

Events-based survey targeting

Survicate Android SDK allows you to launch surveys based on events your users trigger in your app. Your survey will instantly after an event occurs in your app.

Survicate.invokeEvent("eventName");

Event name is case sensitive. If there is any discrepancy between what’s declared in the ‘Triggers’ tab of the Target section in the Survicate panel and the application code, the survey will not appear.

Passing user attributes

You can pass user attributes to Survicate as an additional layer of information about your users. Attributes can be used to:

  • trigger your surveys
  • filter your survey results
Survicate.setUserId("screenName");
Survicate.setUserTrait("traitName", "traitValue");

Bear in mind that user attributes are cached. You only need to provide them once, e.g. when user logs in, not after each init(). You can also change their values at any time to trigger a survey.

Reseting user data for testing purposes

If you need to test surveys on your device, reset() method might be helpful. This method will reset all user data stored on your device (survey views, attributes, information about answered surveys for the targeting engine).

Survicate.reset();

Changelog

1.1.12 (2022-08-04)

Update
Bumping up references: Android to 1.6.5

1.1.11 (2022-07-01)

Update
Bumping up references: Android to 1.6.1 and iOS to 1.8.0
Fixed
Gradle sync failure if referring to React Native 0.68.* and using gradle version lower than 7.2.*

1.1.10 (2022-06-03)

Update
Bumping up references: Android to 1.6.1 and iOS to 1.8.0

1.1.9 (2022-04-29)

Update
Bumping up references: Android to 1.5.14 and iOS to 1.7.2

1.1.8 (2022-04-11)

Update
Bumping up references: iOS to 1.7.1

1.1.7 (2022-03-28)

Update
React version dependency rule, to allow higher version than 16.8.1

1.1.6 (2022-03-23)

Update
Bumping up references: Android to 1.5.12 and iOS to 1.6.7
Fixed
Clean up build.gradle file for fixing Android build issues.

1.1.5 (2022-03-03)

New
Use maven-publish to support React Native 0.67.1
Update
Bumping up references: Android to 1.5.9 and iOS to 1.6.5

1.1.4 (2022-01-20)

Update
Bumping up references: Android to 1.5.6

1.1.3 (2022-01-17)

Update
Bumping up references: Android to 1.5.5

1.1.2 (2021-12-9)

Update
Bumping up references: Android to 1.5.2 and iOS to 1.6.1

1.1.1 (2021-11-10)

Update
Bumping up references: Android to 1.4.5 and iOS to 1.5.8

1.1.0 (2021-10-29)

Update
Bumping up references: Android to 1.3.0 and iOS to 1.5.5
Update
Survicate iOS SDK is now distributed as an XCFramework binary

1.0.5 (2021-05-04)

Update
Bumping up references: Android to 1.2.6

1.0.3 (2021-02-04)

Update
Bumping up references: Android to 1.2.4 and iOS to 1.4.3

1.0.2 (2020-04-23)

Update
Bumping up references: Android to 1.2.0 and iOS to 1.4.0

1.0.1 (2020-03-06)

Update
Bumping up references: Android to 1.1.2

1.0.0 (2020-01-24)

New
Initial version of the SDK, with references to the native Survicate SDKs as follows: Android - 1.0.19 and iOS to 1.3.0

👋 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.