Mobile SDKs Reference

Initialize the SDK

As a first you’ll need to install our SDK in your mobile app. You can find detailed installation methods directly in the Github code repositories.

Each repositories also include a sample application showing you how to load and initialize the client.

Right after loading the SDK, you’ll need to initialize the client by providing your Refiner environment ID. You can find the ID under “Settings > Mobile SDK” in the Refiner dashboard.

You can also activate a debug mode during development. When activated, all communication with our backend server is getting logged.

All Mobile SDKs provide the same set of methods which you can use to identify users, track user behaviour, or launch surveys ad-hoc.

Below we explain what each method does and how you can use it. Please consult the SKD specific documentation for the syntax and code examples.

Identify & track users

Identify user

All users of your app need to be identified with a unique userId using the “Identify User” method.

Next to a unique user ID, you can also provide additional user traits. The provided user traits can be used to segment users in your Refiner account and create custom target audiences for your surveys. You can also use our API to provide the same user traits through a backend integration.

Refiner has a couple of reserved fields you should be aware of. These fields can’t be overwritten or have a certain behaviour attached to them.

You can find examples on how to identify your users for each SDK version here:

When a user logs out from your app or changes user accounts, you can call the “Reset User” method.

If you are using our multi-language surveys feature, you can provide a “locale” string to show surveys in a specific language.

Lastly, you can provide a Identity Verification signature for increased level of security in a production environment.

Start session

The start time of the current user session can be used as the reference time in the Time Delay and Tracked Event survey trigger.

We try to automatically detect when a user starts a new session in your application. A new user session is detected when a user returns to your app after at least one hour of inactivity.

You can choose inform Refiner that a new session started with the startSession method as shown below. You can call this method for example right after a user logs in to your application.

Track event

You can track whenever a user performs an important key action in your app (log-in, purchase, …). User event tracking can be used to created User Segments and Target Audiences in Refiner.

Track screen

Whenever your user navigates to a specific screen in your app, you can use the “Track Screen” method to surface that information to Refiner.

Tracking screens will allow you to launch surveys in specific areas in your app. In the Refiner dashboard, you can create a set of screen rules for each survey which determines on which screens a survey should be launched.

You can choose screen names freely and you don’t need to systematically track each screen. We recommend to track screens on which you might want to show a survey one day.

Advanced options

Add data to response

Next to providing user traits, it is also possible to attach contextual data to survey responses. The “Attach to Response” method lets you provide such data.

Ping server

Depending on your setup, you might want to initiate regular checks for surveys that are scheduled for the current user. For example when you are using time based trigger events, when using our Follow-Up Mode, or when a target audience is based on user data received by our backend API.

The ping method provides an easy way to perform such checks. You can call the Ping method at key moments in a user’s journey, such as when the app is re-opened, or when the user performs a specific action.

Show survey programmatically

Sometimes you might want to show a survey programmatically, directly from your application’s code, instead of relying on targeting rules defined in the Refiner dashboard. The mobile SDK exposes a “Show Form” method that allows you to do exactly this.

Please make sure that your survey is using the “Manual” trigger event in “Targeting” section of the survey editor.

Deferred user identification

The “Set User” method acts as an alternative to the “Identify User” method described above.

In contrast to the Identify User method, the Set User method does not immediately create a user object in your Refiner account. The provided user Id and traits are kept locally in your app and no data is communicated to our servers at first. Only when the user performs a meaningful action in your app (e.g. Track Event or Track Screen is executed) will a user object be created in Refiner. Provided user traits will be attached to the user object when a survey is shown.

The purpose of this alternative method is provide a way to identify users locally when the SDK is initialised but keep the number of tracked users in your Refiner account to a minimum.

Change environment ID

This method allows you to dynamically change the Refiner environment of your app during runtime.

Callback methods

Registering callback functions allows you to execute code at specific moments in the lifecycle of a survey. Our SDK let you register the following callbacks:

MethodDescription
onBeforeShowGets called right before a survey is supposed to be shown.
onNavigationGets called for each step when the user responds to questions or navigates through the survey.
onShowGets called when a survey widget becomes visible to your user.
onCloseGets called when the survey widgets disappears from the screen.
onDismissGets called when the user dismissed a survey by clicking on the “x” in the top right corner.
onCompleteGets called when the user completed (submitted) the entire survey.

To register callbacks, please refer to the following platform specific documentation:

Was this helpful? Let us know with a quick a vote