Pollfish React Native plugin, allows integration of Pollfish surveys into Android and iOS apps.
Pollfish is a mobile monetization platform delivering surveys instead of ads through mobile apps. Developers get paid per completed surveys through their apps.
Pollfish React Native Plugin can be found on npm Registry. The source code and an example app can be found on Github.
- Android SDK 21 or higher using Google Play Services
- iOS 11.0 or higher
- React Native v0.40 or higher
- CocoaPods v1.10.0 or higher
Note: Apps designed for Children and Families program should not be using Pollfish SDK, since Pollfish does not collect responses from users less than 16 years old
Note: Pollfish surveys can work with or without the IDFA permission on iOS 14+. If no permission is granted in the ATT popup, the SDK will serve non personalized surveys to the user. In that scenario the conversion is expected to be lower. Offerwall integrations perform better compared to single survey integrations when no IDFA permission is given
- Create Pollfish Developer account
- Create new apps for each targeting platform (Android & iOS) and grap the API keys
- Install Pollfish plugin and call init function
- Set to Release mode and publish on app store
- Update your app's privacy policy
- Request your account to get verified from Pollfish Dashboard
Pollfish React Native Plugin v2 introduces a different API with added customization options during initialization. If you have already integrated Pollfish React Native Plugin < v2 in you app, please take some time reading the migration guide below.
➤ Migration Guide (Click to expand)
- |
var params = new RNPollfish.Builder('API_KEY'); |
+ |
var params = new RNPollfish.Builder('ANDRPOD_API_KEY', 'IOS_API_KEY'); |
Register as a Developer at www.pollfish.com
Login at www.pollfish.com and add a new app at Pollfish panel in section My Apps and copy the given API key for this app to use later in your init function in your app.
To add Pollfish plugin just type:
Using yarn
yarn add react-native-plugin-pollfish
Using npm
npm install react-native-plugin-pollfish
And for iOS builds
cd ios && pod install && cd ..
Android 12
Apps updating their target API level to 31 (Android 12) or higher will need to declare a Google Play services normal permission in the AndroidManifest.xml file.
Navigate to the android/app/src/main
directory inside your project's root, locate the AndroidManifest.xml file and add the following line just before the <application>
.
<uses-permission android:name="com.google.android.gms.permission.AD_ID" />
You can read more about Google Advertising ID changes here.
iOS 14+
Request IDFA Permission (Recommended but optional)
Pollfish surveys can work with or without the IDFA permission on iOS 14+. If no permission is granted in the ATT popup, the SDK will serve non personalized surveys to the user. In that scenario the conversion is expected to be lower. Offerwall integrations perform better compared to single survey integrations when no IDFA permission is given. Our recommendation is that you should ask for IDFA usage permission prior to Pollfish initialization.
import RNPollfish from 'react-native-plugin-pollfish';
The Pollfish plugin must be initialized with one or two api keys depending on which platforms are you targeting. You can retrieve an API key from Pollfish Dashboard when you sign up and create a new app.
var builder = new RNPollfish.Builder('ANDROID_API_KEY', 'IOS_API_KEY')
.rewardMode(true); // Android & iOS
var builder = new RNPollfish.Builder('ANDROID_API_KEY', null)
.rewardMode(true); // Android only
var builder = new RNPollfish.Builder(null, 'IOS_API_KEY')
.rewardMode(true); // iOS only
You can set several params to control the behaviour of Pollfish survey panel within your app with the use of the RNPollfish.Builder
instance. Below you can see all the available options. Below you can see all the available options.
Note: All the params are optional, except the
releaseMode
setting that turns your integration in release mode prior publishing to the Google Play or App Store.
No | Description |
---|---|
5.1.1 | .indicatorPosition(RNPollfish.Position) Sets the Position where you wish to place the Pollfish indicator. |
5.1.2 | .indicatorPadding(Int) Sets the padding from top or bottom depending on the position of the indicator. |
5.1.3 | .offerwallMode(Boolean) Sets Pollfish SDK to offerwall mode |
5.1.4 | .releaseMode(Boolean) Sets Pollfish SDK to Debug or Release Mode |
5.1.5 | .rewardMode(Boolean) Initializes in reward mode (skip Pollfish indicator to show a custom prompt) |
5.1.6 | .requestUUID(String) Sets a pass-through param to be receive via the server-to-server callbacks |
5.1.7 | .userProperties(Json) Send attributes that you receive from your app regarding a user, in order to receive a better fill rate and higher priced surveys. |
5.1.8 | .rewardInfo(Json) An object holding information regarding the survey completion reward. |
5.1.9 | .clickId(String) A pass throught param that will be passed back through server-to-server callback |
5.1.10 | .userId(String) A unique id ised to identify a user |
5.1.11 | .signature(String) An optional parameter used to secure the rewardConversion and rewardName parameters passed on rewardInfo Json object |
5.1.12 | .placementId(String) The id of the placement to load |
Sets the Position where you wish to place Pollfish indicator -->
Also this setting sets from which side of the screen you would like Pollfish survey panel to slide in.
Pollfish indicator is shown only if Pollfish is used in a non rewarded mode.
There are six different options available:
RNPollfish.Position.topLeft
RNPollfish.Position.bottomLeft
RNPollfish.Position.middleLeft
RNPollfish.Position.topRight
RNPollfish.Position.middleRight
RNPollfish.Position.bottomRight
If you do not set explicity a position for Pollfish indicator, it will appear by default at RNPollfish.Position.topLeft
Note: If you would like to skip the Pollfish Indicator please set the
rewardMode
totrue
Below you can see an example on how you can set Pollfish indicator to slide from top right corner of the screen:
builder.indicatorPosition(RNPollfish.Position.topRight);
The padding from the top or bottom of the screen according to position of the indicator (small icon) specified above (.TOP_LEFT
is the default value)
builder.indicatorPadding(8);
Note: if used in MIDDLE position, padding is calculating from the top
Enables Pollfish in offerwall mode. If not specified Pollfish shows one survey at a time.
Below you can see an example on how you can intialize Pollfish in Offerwall mode:
builder.offerwallMode(true);
Sets Pollfish SDK to Developer or Release mode. If you do not set this param it will turn the SDK to Developer mode by default in order for the publisher to be able to test the survey flow.
You can use Pollfish either in Debug or in Release mode.
- Debug/Developer mode is used to show to the developer how Pollfish will be shown through an app (useful during development and testing).
- Release mode is the mode to be used for a released app in AppStore (start receiving paid surveys).
Note: Be careful to set release mode parameter to true prior releasing to Google Play or AppStore!
builder.releaseMode(true);
Initializes Pollfish in reward mode. This means that Pollfish Indicator (section 4.1.1) will not be shown and Pollfish survey panel will be automatically hidden until the publisher explicitly calls Pollfish show
function (The publisher should wait for the Pollfish Survey Received Callback). This behaviour enables the option for the publishers, to show a custom prompt to incentivize the users to participate in a survey.
Note: If not set, the default value is false and Pollfish indicator is shown.
This mode should be used if you want to incentivize users to participate to surveys. We have a detailed guide on how to implement the rewarded approach here
Note: Reward mode should be used along with the Survey Received callback so the publisher knows when to prompt the user and call
RNPollfish.show()
builder.rewardMode(true);
Sets a pass-through param to be receive via the server-to-server callbacks. You can read more on how to retrieve this param through the callbacks here
Below you can see an example on how you can pass a requestUUID during initialization:
builder.requestUUID("PASS_THROUGH_PARAM");
Passing user attributes to skip or shorten Pollfish Demographic surveys.
If you know upfront some user attributes like gender, age, education and others you can pass them during initialization in order to shorten or skip entirely Pollfish Demographic surveys and archieve better fill rate and higher priced surveys.
Note: You need to contact Pollfish live support on our website to request your account to be eligible for submitting demographic info through your app, otherwise values submitted will be ignored by default.
Note: You can read more on demographic surveys along with a list with all the available options here
An example of how you can pass user demographics can be found below:
const userProperties = {
"gender": "1",
"year_of_birth": "1974",
"marital_status": "2",
"parental": "3",
"education": "1",
"employment": "1",
"career": "2",
"race": "3",
"income": "1",
};
builder.userProperties(userProperties);
A Json object passing information during initialization regarding the reward settings, overriding the values as speciefied on the Publisher's Dashboard
We strogly advise that you should use the Publisher Dashboard to provide Reward Info if your use case does not require a dynamic value.
Field | Description |
---|---|
rewardName |
Overrides the reward name as specified in the Publisher's Dashboard |
rewardConversion |
Overrides the reward conversion as specified on the Publisher's Dashboard. Conversion is expecting a number matching this function ( 1 USD = X Points ) where X is a Double number. |
const rewardInfo = {
rewardName: 'Dollars',
rewardConversion: 1.2
};
builder.rewardInfo(rewardInfo);
Warning: If a
rewardInfo
is set, please make sure to calculate and set the correct signature (5.1.11). By skipping this step you will be unable to receive surveys.
A pass through parameter that will be returned back to the publisher through server-to-server callbacks as specified here
builder.clickId("CLICK_ID");
A unique id used to identify the user
Setting the userId
will override the default behaviour and use that instead of the Advertising Id, of the corresponding platform, in order to identify a user
You can pass the id of a user as identified on your system. Pollfish will use this id to identify the user across sessions instead of an ad id/idfa as advised by the stores. You are solely responsible for aligning with store regulations by providing this id and getting relevant consent by the user when necessary. Pollfish takes no responsibility for the usage of this id. In any request from your users on resetting/deleting this id and/or profile created, you should be solely liable for those requests.
builder.userId("USER_ID");
An optional parameter used to secure the rewardName
and rewardConversion
parameters as provided in the RewardInfo
object (4.1.10). If rewardConversion
and rewardName
are defined, signature
is required to be calculated and set as well.
This parameter can be used to prevent tampering around reward conversion, if passed during initialisation. The platform supports url validation by requiring a hash of the rewardConversion
, rewardName
, and clickId
. Failure to pass validation will result in no surveys return and firing PollfishSurveyNotAvailable
callback.
In order to generate the signature
field you should sign the combination of ${rewardConversion}${rewardName}${clickId}
parameters using the HMAC-SHA1 algorithm and your account's secret_key that can be retrieved from the Account Information section on your Pollfish Dashboard.
Note: Although
rewardConversion
andrewardName
are mandatory for the hashing to work,clickId
parameter is optional and you should add them for extra security.
Note: Please keep in mind if your
rewardConversion
is a whole number, you have to calculate the signature useing the floating point value with 1 decimal point.
builder.signature("SIGNATURE");
Sample JavaScript code to generate valid signatures.
import crypto from 'crypto';
const secret = '<ACCOUNT_SECRET_KEY>';
const rewardConversion = '<REWARD_CONVERSION>';
const rewardName = '<REWARD_NAME>';
const clickId = '<CLICK_ID>';
const message = `${rewardConversion}${rewardName}${clickId}`;
const signature = crypto.createHmac('sha1', secret).update(message).digest().toString('base64');
The id of the placement you wish to load as provided by the publisher dashboard. If not provided, then the default placement of the ad unit will be loaded.
builder.placementId("PLACEMENT_ID");
Example of Pollfish configuration using all the available options
builder.indicatorPosition(RNPollfish.Position.topLeft)
.indicatorPadding(10)
.offerwallMode(false)
.rewardMode(true)
.releaseMode(false)
.requestUUID('REQUEST_UUID')
.userProperties({
gender: '1',
education: '1',
...
})
.clickId('CLICK_ID')
.userId('USER_ID')
.signature('SINGNATURE')
.placementId('PLACEMENT_ID')
.rewardInfo({
rewardName: 'Points',
rewardConversion: 1.3
});
Last but not least. Build the Params
object by invoking .build()
on the RNPollfish.Builder
instance that you've configured earlier and call RNPollfish.init(params)
passing the Params
object as an argument.
var params = builder.build();
RNPollfish.init(params);
// OR
RNPollfish.init(builder.build());
“Survey Serving Technology
This app uses Pollfish SDK. Pollfish is an on-line survey platform, through which, anyone may conduct surveys. Pollfish collaborates with Publishers of applications for smartphones in order to have access to users of such applications and address survey questionnaires to them. When a user connects to this app, a specific set of user's device data (including Advertising ID, Device ID, other available electronic identifiers and further response meta-data is automatically sent, via our app, to Pollfish servers, in order for Pollfish to discern whether the user is eligible for a survey. For a full list of data received by Pollfish through this app, please read carefully the Pollfish respondent terms located at https://www.pollfish.com/terms/respondent. These data will be associated with your answers to the questionnaires whenever Pollfish sends such questionnaires to eligible users. Pollfish may share such data with third parties, clients and business partners, for commercial purposes. By downloading the application, you accept this privacy policy document and you hereby give your consent for the processing by Pollfish of the aforementioned data. Furthermore, you are informed that you may disable Pollfish operation at any time by visiting the following link https://www.pollfish.com/respondent/opt-out. We once more invite you to check the Pollfish respondent's terms of use, if you wish to have more detailed view of the way Pollfish works and with whom Pollfish may further share your data."
If you have any question, like why you do not see surveys on your own device in release mode, please have a look in our FAQ page
Note: Please bear in mind that the first time a user is introduced to the platform, when no paid surveys are available, a standalone demographic survey will be shown, as a way to increase the user's exposure in our clients' survey inventory. This survey returns no payment to app publishers, since it is part of the process users need to go through in order to join the platform. Bear in mind that if a paid survey is available at that point of time, the demographic questions will be inserted at the begining of the survey, before the actual survey questions. Our aim is to provide advanced targeting solutions to our customers and to do that we need to have this information on the available users. Targeting by marital status or education etc. are highly popular options in the survey world and we need to keep up with the market. A vast majority of our clients are looking for this option when using the platform. Based on previous data, over 80% of the surveys designed on the platform require this new type of targeting.
In our efforts to include publishers in this process and be as transparent as possible we provide full control over the process. We let publishers decide if their users are served these standalone surveys or not, in 2 different ways. Firstly by monitoring the process in code and excluding any users by listening to the relevant noitifications (Pollfish Survey Received, Pollfish Survey Completed) and checking the Pay Per Survey (PPS) field which will be 0 USD cents. Secondly, publishers can disable the standalone demographic surveys through the Pollfish Developer Dashboard in the Settings area of an app. You can read more on demographic surveys here.
After your app is published on an app store you should request your account to get verified from your Pollfish Developer Dashboard.
When your account is verified you will be able to start receiving paid surveys from Pollfish clients.
In this section we will list several options that can be used to control Pollfish surveys behaviour, how to listen to several notifications or how be eligible to more targeted (high-paid) surveys. All these steps are optional.
You can get notified when a Pollfish survey is received. With this notification, you can also get informed about the type of survey that was received, money to be earned if survey gets completed, shown in USD cents and other info around the survey such as LOI and IR.
Note: If Pollfish is initialized in offerwall mode then the event parameter will be
undefined
, otherwise it will include info around the received survey.
RNPollfish.addEventListener(RNPollfish.PollfishSurveyReceivedListener, (event) => {
if (event === undefined) {
console.log("Pollfish Offerwall Received");
} else {
console.log(`Pollfish Survey Received - CPA: ${event.surveyCPA}, IR: ${event.surveyIR}, LOI: ${event.surveyLOI}, Class: ${event.surveyClass}, Reward Value: ${event.rewardValue}, Reward Name: ${event.rewardName}, Remaining Completes: ${event.remainingCompletes}`);
}
});
You can get notified when a user completed a survey. With this notification, you can also get informed about the type of survey, money earned from that survey in USD cents and other info around the survey such as LOI and IR.
RNPollfish.addEventListener(RNPollfish.PollfishSurveyCompletedListener, (event) => {
console.log(`Pollfish Survey Completed - CPA: ${event.surveyCPA}, IR: ${event.surveyIR}, LOI: ${event.surveyLOI}, Class: ${event.surveyClass}, Reward Value: ${event.rewardValue}, Reward Name: ${event.rewardName}, Remaining Completes: ${event.remainingCompletes}`);
});
You can get notified when a user is not eligible for a Pollfish survey. In market research monetization, users can get screened out while completing a survey beucase they are not relevant with the audience that the market researcher was looking for. In that case the user not eligible notification will fire and the publisher will make no money from that survey. The user not eligible notification will fire after the surveyReceived event, when the user starts completing the survey.
RNPollfish.addEventListener(RNPollfish.PollfishUserNotEligibleListener, (_) => {
console.log("Pollfish User Not Eligible");
});
You can get notified when a Pollfish survey is not available.
RNPollfish.addEventListener(RNPollfish.PollfishSurveyNotAvailableListener, (_) => {
console.log("Pollfish Survey Not Available");
});
You can get notified when a user has rejected a Pollfish survey.
RNPollfish.addEventListener(RNPollfish.PollfishUserRejectedSurveyListener, (_) => {
console.log("Pollfish User Rejected Survey");
});
You can register and get notified when a Pollfish survey panel has opened. Publishers usually use this notification to pause a game until the pollfish panel is closed again.
RNPollfish.addEventListener(RNPollfish.PollfishOpenedListener, (_) => {
console.log("Pollfish Opened");
});
You can register and get notified when a Pollfish survey panel has closed. Publishers usually use this notification to resume a game that they have previously paused when the Pollfish panel was opened.
RNPollfish.addEventListener(RNPollfish.PollfishClosedListener, (_) => {
console.log("Pollfish Closed");
});
You can manually hide and show Pollfish by calling the functions below, after initialization.
RNPollfish.show();
RNPollfish.hide();
After you initialize Pollfish and a survey is received you can check at any time if the survey is available at the device by calling the following function.
RNPollfish.isPollfishPresent((isPollfishPresent) => {
console.log(isPollfishPresent ? 'Pollfish is available' : 'Pollfish is not available');
});
You can check at any time if the survey panel is open by calling the following function.
RNPollfish.isPollfishPanelOpen((isPollfishPanelOpen) => {
console.log(isPollfishPanelOpen ? 'Pollfish panel is open' : 'Pollfish panel is closed');
});
If you would like to implement the Rewarded approach or just review an example in code, you can review the example app on Github.
You can read more info on how the Native Pollfish SDKs work on Android and iOS or how to set up properly a React Native environment at the following links:
Pollfish Android SDK Integration Guide