I want to make the background agent in my Windows Phone app check for new feeds in the background, i use webclient to download them and i display them in an listbox i use an webbrowser control to display the selected feed to the page it comes from via url i got from the syndicationitem, now i want to save lets say the title or the publishdate to isolated storage and that the background agent checks every 30 min. for feeds and checks if some new feed are available with comparing the the last feed Title or the last publishdate saved already and the newsest on the page, then if a newer feed is there it should send an toast notification with the title of the feed and open my app.
i have nothing done to save the feeds before, i dont know how to do this and i dont know how to use background agents and do thid what i wrote above. I use Microsofts example of an rss reader as background for my app logic. downloading, displaying all that like the sample here - http://msdn.microsoft.com/en-us/library/windowsphone/develop/hh487167(v=vs.105).aspx
here is some code:
i use this to download the feeds
WebClient webClient = new WebClient();
webClient.DownloadStringCompleted += new DownloadStringCompletedEventHandler(webClient_DownloadStringCompleted);
webClient.DownloadStringAsync(new System.Uri("http://wpnovosti.com/feeds/posts/default?alt=rss"));
this i use to show them on my listbox and there is some logic of the live tiles too:
public void UpdateFeedList(string feedXML)
{
StringReader stringReader = new StringReader(feedXML);
XmlReader xmlReader = XmlReader.Create(stringReader);
SyndicationFeed feed = SyndicationFeed.Load(xmlReader);
Deployment.Current.Dispatcher.BeginInvoke(() =>
{
// Bind the list of SyndicationItems to our ListBox.
feedListBox.ItemsSource = feed.Items;
SystemTray.SetProgressIndicator(this, null);
//Live Tiles
ShellTile appTile = ShellTile.ActiveTiles.First();
if (appTile != null)
{
FlipTileData TileData = new FlipTileData()
{
Title = "",
BackTitle = "WP Novosti",
BackContent = feed.Items.First().Title.Text,
WideBackContent = feed.Items.First().Title.Text,
Count = 0,
};
appTile.Update(TileData);
}
else
{
}
});
this i use if an item is selected on the listbox:
public void feedListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
ListBox listBox = sender as ListBox;
if (listBox != null && listBox.SelectedItem != null)
{
// Get the SyndicationItem that was tapped.
SyndicationItem sItem = (SyndicationItem)listBox.SelectedItem;
// Set up the page navigation only if a link actually exists in the feed item.
if (sItem.Links.Count > 0)
{
Uri uri = sItem.Links.FirstOrDefault().Uri;
NavigationService.Navigate(new Uri("/Pregled.xaml?url=" + uri, UriKind.Relative));
UpdateFeedList(State["feed"] as string);
}
}
}
the rest is just displaying this passed url on another page via webbrowser control. how can i make this really work now like i want described on top?!