Notification every time a player finishes a round

Anyone know if there is a way to implement this aside from polling the server every few seconds (not ideal)? I want an app that pushes the user a notification whenever they finish a round.

Thanks!

The only way to do this is to poll the server. I wouldn’t expect push notification service form this unless someone builds a service like that on top of the api.

It’s not so difficult to poll the API.
Easiest way would be to fire up a Heroku app or something with Node JS. Use my JS bindings (https://github.com/DerFlatulator/halo5api), and a service like PushBullet for dispatch to your phone.

Something like this might do the trick: (
(EDIT: Waypoint ate my indendation, here’s a gist)

> var prevDate = new Date();
>
> setInterval(function () {
> h5.stats.playerMatches(“Der Flatulator6”, function (data) {
> // grab the matches
> var matches = data.Results;
>
> // sort them to find most recent
> matches.sort(function (a, b) {
> return new Date(b.MatchCompletedDate.ISO8601Date)
> - new Date(a.MatchCompletedDate.ISO8601Date);
> });
>
> var mostRecent = matches[0];
>
> var scoreA = mostRecent.Teams[0].Score;
> var scoreB = mostRecent.Teams[1].Score;
> var curDate = new Date(mostRecent.MatchCompletionDate.ISO8601Date
> if (curDate > prevDate) {
> // we have a new completed game
> prevDate = curDate;
> // use something like PushBullet to send a notification
> request.post({
> url: “https://api.pushbullet.com/v2/users/me”,
> body: {
> type: “note”,
> title: “A match has been completed”,
> body: scoreA + “-” + scoreB
> },
> json: true,
> headers: {
> ‘Access-Token’: ‘{pushbullet API token}’
> }
> }, function () { /* done */ });
> }
>
> });
> }, 1 * 60 * 1000); // every 1 minute

> 2533274852053435;3:
> > // sort them to find most recent
> > matches.sort(function (a, b) {
> > return new Date(b.MatchCompletedDate.ISO8601Date)
> > - new Date(a.MatchCompletedDate.ISO8601Date);
> > });

Sadly, this doesn’t quite work as expected. The API documents the “MatchCompletedDate” as just the date, there is no time involved. So, we can’t get an ordering on the actual matches themselves at the moment, except maybe to depend upon the ordering of the results themselves (which is usually a sketchy thing to do). This is definitely something that I would love to see changed.

> // The date and time when match ended. Note that this is different than the
> // processing date, once matches end they typically take a small amount of time to
> // process. The processing date is not available through this API. The time // component of this date is always set to “00:00:00”. This is expressed as an ISO
> // 8601 combined Date and Time.

> 2533274808499978;4:
> Sadly, this doesn’t quite work as expected. The API documents the “MatchCompletedDate” as just the date, there is no time involved. So, we can’t get an ordering on the actual matches themselves at the moment, except maybe to depend upon the ordering of the results themselves (which is usually a sketchy thing to do). This is definitely something that I would love to see changed.

I noticed this in the theatre last night, no time stamp isn’t ideal when viewing films nor is it useful for stats apps.

You can also handle push notifications through AWS SNS. AWS provides great documentation and takes little to no time to setup. The dashboard is a bit of a UX nightmare, but you get the hang of it. Also the Free Trial lasts for a year and is typically loads more than enough for small town production apps.

Thanks for all the responses! The pushes aren’t the problem (I was going to use Parse, it’s worked great for me with other apps) but the problem is more figuring out when a match ends. I’ll probably implement polling or something (and hope I can get a higher API request limit later :))