I understood that my previous question was too vague and didn’t explain awfully much. I hope this post will be more understandable.
I’m currently creating an app which will pull certain @Twitter feeds as well as certain Twitter #hashtags and show them in an Windows 8 Modern UI app. Showing these feeds in-app works great, but I want to notify the user with a toast notification whenever a new tweet is either posted by one of the certain @Twitter users, OR when a new tweet is marked with a certain #hashtag.
From my last question, I was made aware of Azure’s role in this, and after trying to create a working notification script with snippets I’ve found so far, I’ve ended up with something which doesn’t really work:
(based on: http://webhole.net/2010/05/10/how-to-check-for-new-tweets-from-a-user/)
function insert(item, user, request) {
var oldTweetId=0;
var username="9gag";
var url='http://api.twitter.com/1/statuses/user_timeline/'+username+'.json?callback=?';
setInterval(checkStream,5000);
function checkStream()
{
$.getJSON(url,function(tweets){
if(tweets[0].id!=oldTweetId)
{
request.respond();
push.wns.sendToastText04( {
text1: "ny tweet!"
}, {
success: function(pushResponse) {
console.log("Sent push:", pushResponse);
}
});
}
});
}
}
Would anyone know how to actually make this work? I’ve tried a few different approaches, but to avoid unnecessary non-working code snippets, I’ll post my latest one (which doesn’t work).
Toast notifications can be made by your running app, or they can be pushed to a user’s device by a two-part web service. It’s not obvious to me where exactly your JS code snippet runs. Are you running that in a Node.js app on a server and calling WNS?
I would first work on getting toast notifications to work in your standalone app, not using the push service. The Windows 8 Toast notification sample in JS/C# will show you how. Once you’re happy with locally generated toast notifications, you can tackle using WNS.
The two-part web service I mentioned consists of:
Probably the simplest way to do push notifications from the cloud is to use Windows Azure Mobile Services. A sample by Nick Harris will show you how, but you’ll want to read up on WAMS first.