Android
Installation
To install Pulse Insights in your application, follow those steps:
Add the
maven repositories target
and thegoogle 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 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
If your app is targeting API level 28 (Android 9.0) or above, please make sure the following
<uses-library>
element description has been added inside the<application>
element ofAndroidManifest.xml
. Check the developer documentation for more detail.
Usage
1. Initialization
When your application starts, you should initialize the library using the snippet below:
Replace YOUR_ACCOUNT_ID with your own PulseInsights ID, for example: 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 to display the survey view or the invite widget.
After this initial step, you can fetch the PulseInsights object as below:
2. View tracking
PulseInsights allows targeting surveys to a given screen name. In order for the SDK to know the current screen name, you can use the following method to notify it of the current screen name change:
For example, you can override the onCreate function or the onActivityResult function on the Activity class:
3. Survey polling
The PulseInsights SDK will automatically regularly fetch surveys that would match various targeting conditions based on a frequency that you can override as shown below:
If you want to manually fetch new surveys, you can use this method:
4. Render a specific survey
It is also possible to manually trigger a survey by its id:
5. Inline surveys
Inline surveys are rendered within the content of the application, instead of overlaying the application content.
In order to integrate inline surveys, you can programmatically create the InlineSurveyView
object by assigning an identifier and inserting it into a view:
You still can integrate 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
6. Survey rendering
You can pause and resume survey rendering with the following method:
And check the current configuration with the following method:
true: survey rendering feature is enabled
false: survey rendering feature is paused
It is 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.
7. Client Key
Client key can be set using this method:
The configured client key can be fetched with this method:
8. Preview mode
Preview mode can be enabled or disabled by:
Preview mode can be programmatically enabled/disabled by this method:
It is 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:
9. Callbacks
If you want to know if a survey has been answered by the current device, this method can be used:
It is also possible to configure a callback to be executed when a survey has been answered:
10. Context data
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 check this article for learn more about the
ExtraConfig
class.
11. Device data
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.
12. Advanced
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 to manually config the context, you can call the following method:
And get the context object that has been configured
13. Others
1. ExtraConfig
The ExtraConfig is the class to which you can apply the additional configuration from the initialization of the Pulse Insights library:
You can apply the additional config with the following sub variables:
automaticStart
Survey rendering
true
true - survey rendering will automatically started from the initialization false - survey rendering will not started from the initialization
previewMode
Preview mode
false
true - turn preview mode on false - turn preview mode off
customData
Context data
new HashMap<>()
Save data along with survey results
Themes
You can configure approximately 50 properties such as font color and size using SDK Themes in the Console:
Styling is not driven by CSS, but uses native components & formatting instead.
To create a mobile app compatible theme in the Pulse Insights Console:
Click the Settings dropdown menu from the top navigation bar
Select "Themes"
Click the "New Theme" button
Give a name to your theme
In the "Type" dropdown menu, select "Native"
Input your Native JSON theme into the code box
"Update"
Uninstall
Remove 1.0.9 or later
Remove whatever you added when you go through the install flow
Sync or rebuild your project
Remove 1.0.8 or earlier
To remove the library from your project, please follow the steps below:
In the IDE, select [File]->[Project Structure]
Select
Modules
from the left menu and find the library you named when you installed. Select remove or -, then click ok to confirm.Find and remove the following
implementation
statement from thedependencies
section from theapp level
build.gradle script file.
Open the project folder, find and delete the sub-folder with the library display name.
Last updated