So, to make pollfish showing in your app is very easy. Even with libgdx, you just make some changes to your androidlauncher.java , like that below.
Recently there was an official guide for libgdx posted, be sure to check it first -> https://github.com/libgdx/libgdx/wiki/Pollfish-in-libgdx
First of all, follow the official guide -> https://www.pollfish.com/android
1)Register and get your developer id key.
2)Add the pollfish sdk as instructed in the guide
3)Add pollfish init method to the onResume method of androidlauncher:
protected void onResume() {
super.onResume();
PollFish.init(this, "your id here", Position.TOP_RIGHT, 5);
}
4)Make your AndroidLauncher class implement PollfishSurveyCompletedListener
and add such a method:
@Override
public void onPollfishSurveyCompleted(boolean arg0, int arg1) {
main.surveyCompleted();
}
My libgdx main class has a method surveyCompleted that adds 15 double jumps and saves preferences.
Change the main class initialiation in onCreate, so that you can use main reference in other methods
main = new Main();
initialize(main, config);
Now your app will show pollfish icon when a survey is available, and a surveyCompleted() method will be executed when user completes a survey.
I also tried to make the pollfish icon hide during gameplay using PollFish.hide() method, but seems to me that there are some problems with libgdx, as it steals focus from the Android activity, my hide method call didnt hide the icon. If you implemented successfully the hide method in your libgdx game, post in comments!
Hey Alex, regarding your show/hide issues please have a look on a workaround here:
ReplyDeletehttps://github.com/libgdx/libgdx/wiki/Pollfish-in-libgdx
Thanks Andreas! I will check it!
Delete