B4A Library Pollfish -A new innovative way to monetize your apps! Forget about ads!

Hello everyone,

My name is Andreas and I am one of the founders of Pollfish (http://www.pollfish.com). Pollfish is a new innovative way of monetization for mobile apps that delivers 10-20x more revenue than classic mobile advertising! At Pollfish we monetize with surveys! Integration of the single line SDK is easy, fast and does not reserve any extra space on the developer's app UI as its displayed as an overlay:



Pollfish provides minimal intrusion and high payouts. Users responding to Pollfish surveys win prizes - happy users! Pollfish surveys are displayed through an app only when a paid survey is available, otherwise nothing is shown to the users as if Pollfish was never integrated in the app before. The minimum revenue for each completed survey through an app is $0.30! Payments occur on a monthly basis with minimum payment at $30.0.

In addition, Pollfish can be used along with any other ad platform as it is displayed as an overlay and it can be placed anywhere in an app, just to bring extra revenue! Most of our developers use us as a supplementary source of revenue at the moment along with other ad platforms! Pollfish inventory includes both global and localised surveys on different regions.

Moreover, app owners can perform internal surveys on their users for free. With this option they can talk to their own user base, understand better their needs, listen to feature requests and get real feedback for their app. And all that for free just by using Pollfish.

You can see our video below:

Video

Or download Pollfish Android demo app from Google Play, where you can see how a Pollfish survey is displayed through a mobile app!

Demo App

You can find Pollfish Android SDK B4A Wrapper and integration manual here.

If you need any help, just pm me.

Cheers,

Andreas

1571d1387290799t-pollfish-new-innovative-way-monetize-your-apps-forget-about-ads-unnamed.jpg
1572d1387291518t-pollfish-new-innovative-way-monetize-your-apps-forget-about-ads-unnamed2.jpg
 

tpakis

Active Member
Licensed User
Longtime User
With Inline Java code you don't need a wrapper anymore. Here are the steps to run pollfish:
1) Add Google play services and pollfish sdk in project attributes (after you download Pollfish SDK):
B4X:
#AdditionalRes: ...correct path...\libproject\google-play-services_lib\res, com.google.android.gms
    #AdditionalJar: ...correct path...\pollfish-googleplay-4.2.1.jar

2) Add these lines of code at the end of your project:
B4X:
#If JAVA
import com.pollfish.main.PollFish;
import com.pollfish.main.PollFish.ParamsBuilder;
import com.pollfish.constants.Position;

public void _onResume() {
    PollFish.initWith(this, new ParamsBuilder("YOUR API KEY").build());
}
#End IF

If you want to test it the change the above line with:
B4X:
PollFish.initWith(this, new ParamsBuilder("YOUR API KEY").releaseMode(false).build());

Don't forget to add internet permission!

That's it you are done :)
 
Last edited:

beaker

Member
Licensed User
Ok, so I'm just about ready to shoot myself having tried for most of yesterday trying to get this working in B4A 6.0 (and previously 5.80). I've downloaded and unzipped the Pollfish wrapper library and put the PollfishB4A.jar and PollfishB4A.xml files in my 'Additional Libraries' folder as per usual.

These are the instructions from the document included in the wrapper library zip file with my comments in bold:
  1. Download PollfishB4A.zip and decompress it into Basic4Android Extralibs folder. Ok, so I'm guessing by "Extralibs" they mean the "Additional Libraries" folder.
  2. Setup Google Play services for your app, as described here(https://developer.android.com/google/play-services/setup.html). How do we do this when developing in B4A 6.0? The instructions linked to are not for B4A and I have no idea how to apply them to B4A 6.0.
  3. Check pollfishB4A in the libs panel. Ok
  4. Add #extends:com.pollfish.pollfishB4A.PollFishActivity to the Activity Attributes region. Ok
  5. Declare a variable of type Pollfish in Sub Globals. Ok
  6. Initialize it in the Sub Activity_Resume. Ok
  7. Set to Release mode and release in Store. What if we're not ready to release in store (even as beta)? Can we test it locally in debug mode through B4A Bridge?
  8. Update your privacy policy. Ok

I've included the following lines in the manifest:

SetApplicationAttribute(android:debuggable, "true")
AddPermission(android.permission.INTERNET)


I'm not sure whether the AddPermission line is required but I saw it quoted in some of the instructions so included it. I've used the API key given to me by Pollfish for my app in the 'Initialize' call.

I can get the app to compile and run without error but no surveys appear and I'm guessing this has something to do with the Google Play Services not being set up.
  1. Can anyone confirm that I'm generally on the right track and if possible give me some instructions on how to set up the Google Play Services correctly in B4A 6.0?
  2. Should I be using the inline Java method rather than the wrapper library and if so how do we call the show & hide methods or handle Pollfish events?
I've also tried the "AndroTest" demo B4A app that Pollfish provide but that doesn't show any surveys either. I had to use the API key they provided for my other app for this too. I don't know whether there's a different key I should've used instead. Any ideas on why this doesn't work either?

Sorry if these seem like (too many!) stupid questions but I'm damned if I can get this working with the information I've managed to find so far.

Thanks for any help anyone can give me.
 
Last edited:

tpakis

Active Member
Licensed User
Longtime User
The old library doesn't support the new pollfish SDK.
I am not sure about how you can access events with inline java but for manual show and hide you can add to the java code:
B4X:
public void showpoll {
    PollFish.show();
}
public void hidepoll {
    PollFish.hide();
}

and call them from a button:

B4X:
Sub Button1_Click
  NativeMe.Runmethod("showpoll",Null)
End Sub

of course for inline java:
B4X:
Sub Process_Globals
   Private NativeMe As JavaObject
End Sub

Sub Activity_Create(FirstTime As Boolean)
   If FirstTime Then
     NativeMe.InitializeContext
   End If
End Sub
 

beaker

Member
Licensed User
Thanks tpakis that was very useful. I've now changed my code as per your posts above. I found I had to add brackets after showpoll and hidepoll in their declarations otherwise I got an error.

My inline Java now looks like this:

B4X:
#If JAVA
import com.pollfish.main.PollFish;
import com.pollfish.main.PollFish.ParamsBuilder;
import com.pollfish.constants.Position;

public void _onResume() {
        PollFish.initWith(this, new ParamsBuilder("API-KEY").releaseMode(false).build());
}

public void showpoll() {
    PollFish.show();
}

public void hidepoll() {
    PollFish.hide();
}
#End If

I've added the following to Process_Globals:

B4X:
Dim NativeMe As JavaObject

I've also added the following to the manifest:

B4X:
'************ Google Play Services Base ************
AddApplicationText(
  <activity android:name="com.google.android.gms.common.api.GoogleApiActivity"
  android:theme="@android:style/Theme.Translucent.NoTitleBar"
  android:exported="false"/>
    <meta-data
  android:name="com.google.android.gms.version"
  android:value="@integer/google_play_services_version" />
)
'************ Google Play Services Base (end) ************

I was then getting the following error:

AndroidManifest.xml:26: error: Error: No resource found that matches the given name (at 'value' with value '@Integer/google_play_services_version').

I then added the following to the Project Attributes #Region:

B4X:
  #AdditionalJar: <my_path>\pollfish-googleplay-4.2.1.jar
    #AdditionalJar: com.google.android.gms:play-services-base

... and the following to Activity_Create:
B4X:
If FirstTime Then
    NativeMe.InitializeContext
End If

I think that's all the changes I made to my project to get it to work. I'm now playing with the other options detailed here: https://www.pollfish.com/docs/android/google-play to get it behaving exactly how I want it. I've noticed that there's some info on handling the Pollfish events on that page I linked to as well but I'm not sure how we implement them in B4A. It's getting late here now so I'm off to bed. I'll continue again in the morning!

Thanks for your help.
 

BitsAndBytes

Active Member
Licensed User
I am geting the following error

...Compiling generated Java code. Error
javac 1.8.0_101
src\androidapp\app\main.java:20: error: package com.pollfish.pollfishB4A does not exist
public class main extends com.pollfish.pollfishB4A.PollFishActivity implements B4AActivity...
 

tpakis

Active Member
Licensed User
Longtime User
Have you removed -unticked the old library from the project? I'm saying this because pollfishB4A shouldn't exist so it shouldn't cause an error.
 

BitsAndBytes

Active Member
Licensed User
Yes but the problem now is how i can add java event listeners when for example a survey is received????
 

BitsAndBytes

Active Member
Licensed User
I made it all ready work and i can see surveys and complete them. But now i am missing the inline java listeners to undestand when an survey received, closed ,completed etc
 

tpakis

Active Member
Licensed User
Longtime User
This is the code for accessing all the events of the pollfish sdk. Watch out it's on releasemode(false) for testing so it works only on debug, remove it for release

B4X:
Sub onPollfishClosed
    Log("onPollfishClosed")
End Sub
Sub onPollfishOpened
    Log("onPollfishOpened")
End Sub

Sub onUserNotEligible
    Log("onUserNotEligible")
End Sub
Sub onPollfishSurveyCompleted(playfulsurvey As Boolean,surveyprice As Int)
    Log("onPollfishSurveyCompleted"& " "&playfulsurvey&" "&surveyprice)
End Sub
Sub onPollfishSurveyReceived(playfulsurvey As Boolean,surveyprice As Int)
    Log("onPollfishSurveyReceived"& " "&playfulsurvey&" "&surveyprice)
End Sub
Sub onPollfishSurveyNotAvailable
    Log("onPollfishSurveyNotAvailable")
End Sub
'In all Java code the name of the subs must be in lower case, if the subs are called from activity then processBA.raise... else ba.raise...
#If JAVA
import anywheresoftware.b4a.keywords.Common;
import com.pollfish.main.PollFish;
import com.pollfish.main.PollFish.ParamsBuilder;
import com.pollfish.constants.Position;
import com.pollfish.interfaces.PollfishSurveyNotAvailableListener;
import com.pollfish.interfaces.PollfishSurveyCompletedListener;
import com.pollfish.interfaces.PollfishUserNotEligibleListener;
import com.pollfish.interfaces.PollfishOpenedListener;
import com.pollfish.interfaces.PollfishClosedListener;
import com.pollfish.interfaces.PollfishSurveyReceivedListener;

public void _onResume() {
        ParamsBuilder paramsBuilder = new ParamsBuilder("YOURAPIKEY")
.pollfishSurveyReceivedListener(new PollfishSurveyReceivedListener() {
    @Override
    public void onPollfishSurveyReceived(final boolean playfulSurvey, final int surveyPrice)
    {
    if (processBA.subExists("onpollfishsurveyreceived")) {
        processBA.raiseEventFromUI(this, "onpollfishsurveyreceived", new Object[] {playfulSurvey,surveyPrice});
    }
    }
    })
.pollfishSurveyNotAvailableListener(new PollfishSurveyNotAvailableListener() {
    @Override
    public void onPollfishSurveyNotAvailable(){
    if (processBA.subExists("onpollfishsurveynotavailable")) {
        processBA.raiseEventFromUI(this, "onpollfishsurveynotavailable", null);
    }
    }
    })
.pollfishSurveyCompletedListener(new PollfishSurveyCompletedListener() {
    @Override
    public void onPollfishSurveyCompleted(final boolean playfulSurvey, final int surveyPrice)
    {
    if (processBA.subExists("onpollfishsurveycompleted")) {
        processBA.raiseEventFromUI(this, "onpollfishsurveycompleted", new Object[] {playfulSurvey,surveyPrice});
    }
    }
    })
.pollfishUserNotEligibleListener(new PollfishUserNotEligibleListener() {
        @Override
        public void onUserNotEligible(){
         if (processBA.subExists("onusernoteligible")) {
        processBA.raiseEventFromUI(this, "onusernoteligible", null);
        }
        }
        })
.pollfishOpenedListener(new PollfishOpenedListener() {
        @Override
        public void onPollfishOpened(){
        if (processBA.subExists("onpollfishopened")) {
        processBA.raiseEventFromUI(this, "onpollfishopened", null);
        }
        }
        })
.pollfishClosedListener(new PollfishClosedListener() {
        @Override
        public void onPollfishClosed(){
        if (processBA.subExists("onpollfishclosed")) {
        processBA.raiseEventFromUI(this, "onpollfishclosed", null);
        }
        }
        })
        .releaseMode(false)
        .build();

    PollFish.initWith(this, paramsBuilder);
}

#End IF
 

tpakis

Active Member
Licensed User
Longtime User
I tried the sample and works great on android 5 emulator , in debug mode since it's releasemode(false). But before it did, i had to add this to the manifest for play services to work:
B4X:
'************ Google Play Services Base ************
AddApplicationText(
  <activity android:name="com.google.android.gms.common.api.GoogleApiActivity"
  android:theme="@android:style/Theme.Translucent.NoTitleBar"
  android:exported="false"/>
    <meta-data
  android:name="com.google.android.gms.version"
  android:value="@integer/google_play_services_version" />
)
'************ Google Play Services Base (end) ************

I have faced a weird issue with android 7 with app ui becoming unresponsive with pollfish 4.3.1 sdk and not with 4.2.1 . I will further investigate it.
 

tpakis

Active Member
Licensed User
Longtime User
Something funny is happening with 7 nougat emulator. When i use debug mode with the latest sdk the app becomes unresponsive, and sometimes stops with "waiting for debugger to connect" .If i close the app and restart it from inside the emulator not from b4a then the debugger connects, and everything works properly with the app. I really don't understand what is happening.
 
Top