Skip to content

Feeds

Introduction

StreetHawk's Feed component is used for sending feeds to your application.

Prerequisite

StreetHawk Feed component depends on StreetHawk's Analytics components. This document assumes that you have already integrated StreetHawkAnalytics component. if not then click here for detailed documentation on StreetHawkAnalytics components which describes steps to integrate Analytics component.

Integration steps

  • Include StreetHawk Feeds Component

1.In Xamarin Studio, double click on Components folder
2.Click on "Get More Components", and search for StreetHawk Feeds. Click Add to App
3.Once downloaded, click on Add to Project

  • Add streethawkfeeds plugin
 <manifest>
... 
    <application>   
        ...
        <receiver
                android:name="com.streethawk.library.feeds.SHCoreModuleReceiver"
                android:enabled="true"
                android:exported="true" >
                <intent-filter>
                    <action android:name="com.streethawk.intent.action.APP_STATUS_NOTIFICATION" />
                </intent-filter>
        </receiver>
    </application>
</manifest>
  • Include Statements

Add the following include statements in you application's launcher class

using Com.Streethawk.Library.Core;
using Com.Streethawk.Library.Feeds;
  • Initialise StreetHawk and register ISHFeedItemObserver

Set application's app_key and call StreetHawk Init from OnCreate function of your application's launcher class as shown below

namespace XamHawkFeeds
{
    [Activity (Label = "XamHawkFeeds", MainLauncher = true, Icon = "@mipmap/icon")]

// Register Feed Item observer to receive feeds from StreetHawk

    public class MainActivity : Activity,ISHFeedItemObserver
    {
        protected override void OnCreate (Bundle savedInstanceState)
        {
            Xamarin.Insights.Initialize (XamarinInsights.ApiKey, this);
            base.OnCreate (savedInstanceState);
            // Set our view from the "main" layout resource
            SetContentView (Resource.Layout.Main);
            StreetHawk.Instance.SetAppKey ("SHSample");
            StreetHawk.Instance.Init (Application);
            SHFeedItem.GetInstance (this).RegisterFeedItemObserver (this);
        }
        public void ShFeedReceived(Org.Json.JSONArray value){
            //Add code to display feed data here
        }
    }
}
  • Fetch Feeds

Fetch feeds by calling ReadFeedData as shown below.

SHFeedItem.GetInstance(this).ReadFeedData(0);