Skip to content

In-App Message / Feeds


Feed module is used for sending In-App messages to your application. The module is handy if you wish to

  • Store locally push message received by application for future reference by application users
  • Send message to users who have denied receiving push messages
  • Feed items.

Integration Steps

Integration of StreetHawk's Analytics module is the prerequisite for this module. Click here for the documentation on StreetHawk Analytics module.

  • Adding dependencies

For Android Studio as your IDE, add the following code in application's build.gradle under dependencies.

dependencies {
   compile 'com.streethawk:feeds:1.8.22'
  • Implement ISHFeedItemObserver

Implement ISHFeedItemObserver in the activity you wish to present the feed item

import com.streethawk.library.feeds.ISHFeedItemObserver;
import com.streethawk.library.feeds.SHFeedItem;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

public class Feeds extends AppCompatActivity implements ISHFeedItemObserver {

    public void shFeedReceived(final JSONArray feeds) {

//TODO: Parse and display feed items here

  • Request feed item from server

Call feed module's readFeedData API to request feeds from the server.

    public void onResume() {
int offset = 0;

     * Read feed data after the given offset number
     * @param offset
    private void fetchFeedData(int offset){
  • Notify user when new feed is available (Optional)

You can further notify users when a new feed item is available (sing badges or local notifications) by implementing BroadCastReceiver to read action com.streethawk.intent.action.newfeed as shown below.

  • Add Broadcast receiver in AndroidManifest.xml
           <action android:name="com.streethawk.intent.action.newfeed" />
  • Add custom code in onReceive function
public class FeedBroadCastReceiver extends BroadcastReceiver {
    public FeedBroadCastReceiver() {

    public void onReceive(Context context, Intent intent) {
        //TODO: Add code to display local notification or badge 

  • Sending Feed Acks

Send the feedack to acknowledge receipt of an individual feed item


where feedId is the identifier for the feed item received from StreetHawk server

  • Sending FeedResults

Send Feed results to report actions taken by the user on a feed item. Feed result can be one the three values as listed below

Title Feed Result Description
Accepted 1 Denotes a positive action on Feed item. For example Rate
Later 0 Denotes a neutral action on Feed item. For example Later.
Declined -1 Denotes a negative action on Feed item. For example Cancel

where feedId is the identifier for the feed item received from StreetHawk server and result is one of the values listed in above table.