Android
Last updated
Was this helpful?
Last updated
Was this helpful?
To see the latest release notes, please visit our .
To install PulseInsights on your application, follow those steps:
Add the maven repositories target
and the google repositories target
in the build.gradle script of the project level as the following example shows, make sure you have google() in the top of repositories section in the both of buildscript and allprojects
Add the dependencies description in the build.gradle script of the app level as the following example shows
You only need to modify this implementation description with the available version name when you want to update the SDK in the future
Sync the gradle script
When you application start, you should initialize the library using the snippet below:
Replace YOUR_ACCOUNT_ID with your own PulseInsights ID, like PI-12345678.
You should subclass Application
and provide a helper method that returns your application's PulseInsights object:
You also need to provide the context of the Activity object for display the survey view or the invite widget
After this initial step, you can fetch the PulseInsights object as below:
PulseInsights allow to target surveys given a screen name. In order for the SDK to know about the current screen name, you can use the following method to notify the SDK of the current screen name change:
For example, you can override the onCreate function or the onActivityResult function on the Activity class:
The PulseInsights SDK will automatically regularly fetch surveys that would match various target conditions, based on a frequency that you can override as show below:
If you want to manual fetch new surveys, you can also directly use this method:
It's also possible to manual trigger the rendering of a survey by its id:
Inline surveys are rendered within the content of the application, instead of being rendered as pop-ups, overlaying the application content.
In order to integrate the inline surveys, you can programmatically create the InlineSurveyView
object with giving an identifier and insert it into a view:
You still can integrate the inline surveys by adding the inline survey on the XML layout with the survey view class com.pulseinsights.pisurveylibrary.util.InlineSurveyView
In this case, you can assign the identifier on the inline view by using the method setIdentifier
You can pause and resume the survey rendering feature with the following method:
And check the current configueration with the flollowing method:
true: survey rendering feature is working
false: survey rendering feature has been paused
It's also possible to pause the survey rendering feature from the initialization of the Pulse Insights library:
You can check this article for learn more about the
ExtraConfig
class.
Client key can be setup using this method:
The configured client key can be fetched with this method:
The preview mode can be enable/disable by shake motion according the following rule:
The preview mode can be programally enable/disable by this method:
It's also possible to set the preview mode from the initialization of the Pulse Insights library:
You can check this article for learn more about the
ExtraConfig
class.
In order to check the status of preview mode, use this method:
If you want to know if a survey has been answered by the current device, this method can be used:
It's also possible to configure a callback to be executed when a survey has been answered:
You can save context data along with the survey results, or for a refined survey targeting, using the customData
config attribute, for example:
You can also use pi.clearContextData()
to clear all data you added before.
You can check this article for learn more about the
ExtraConfig
class.
If you want to set device data, which will be saved along the survey results, the method setDeviceData
can be used as follows:
setDeviceData
can be called at any time, it will trigger a separate network request to save the data.
The default host is "survey.pulseinsights.com". If you want to target the staging environment, or any other environment, it's possible to override the default host:
The debug mode can be turned on and off:
PulseInsights creates a unique UDID to track a given device. If you wish to reset this UDID, you can call the following method:
If you want manually config the context, you can call the following method:
And get the context object which been configured
1. ExtraConfig
The ExtraConfig is the class which you can apply the additioanl configuration from the initialization of the Pulse Insights library:
You can apply the additional config with the following sub variables:
automaticStart
true
true - survey rendering will automatically started from the initialization false - survey rendering will not started from the initialization
previewMode
false
ture - turn the peview mode on false - turn the preview mode off
customData
new HashMap<>()
Save data along with survey results
Remove whatever you added when you went through the install flow
Sync or rebuild your project
If your app is targeting API level 28 (Android 9.0) or above, please make sure the following <uses-library>
element description been added inside the <application>
element of AndroidManifest.xml
, you can check for more detail