Skip to content

Handling push result inside your application (Android)

Introduction

Push results from StreetHawk SDK keeps track of user action to a push notification. Starting release 1/1.6.0, the SDK shares user's action or push results with application . This gives more flexibility to application developers and let them customise the logic for a push notification based on the action taken by the user.

Consider a use case for a Rate App campaign which asks application users to rate your application on Google Play store. While there will be users who are happy to rate the application, there might be few as well who decides the other way. For all those users, application can present the user with a feedback inside the application and get their opinion.

Steps

  • Implement ISHObserver
public class MainActivity extends Activity implements ISHObserver{

....
....
}
  • Add code in onReceiveResult
@Override
    public void onReceiveResult(PushDataForApplication resultData, int result) {
    /* 
        Result:
        -1 = declined
        0 = Postponed
        1 = Accepted
         */        
    if(result==-1 || result==0){
            if(resultData.getAction()==PushDataForApplication.ACTION_RATE_APP){
                Intent intent = new Intent(getApplicationContext(),RateFeedBackForm.class);
                startActivity(intent);
            }
        }
    }
  • Register ISHObserver instance
StreetHawk.INSTANCE.registerSHObserver(this);
....
...
StreetHawk.INSTANCE.init(getApplication());