Push Listener

On Android, the TUNE SDK provides a TunePushListener interface that can be implemented to access extraPushPayload from a Tune Push Message and decide if a notification should be displayed.

Usage

Start by creating a class that implements a TunePushListener.

public class MyPushListener implements TunePushListener {
    @Override
    public boolean onReceive(boolean isSilentPush, JSONObject extraPushPayload) {
        // Add logic to determine whether or not you want the push to be displayed.
        // Return true to display a push, false otherwise. If you return true here, but it's a silent push, a notification does not display.
        return true;
    }
}

Then, create an object of the listener you implemented. For example,

MyPushListener listener = new MyPushListener();

Finally, tell the TUNE SDK to use the push listener you've created. This call should go after Tune.init:

Tune.getInstance().setPushListener(listener);

You're set! Any TUNE push notifications you receive in your app will be passed through the `onReceive` of this listener to access the extraPushPayload and decide if the push should be displayed.

Have a Question? Please contact support@tune.com for technical support.