开发者

How to achieve temperature badge for weather app?

Look at this app for example.

How to achieve temperature badge for weather app?

How does this work behind the scenes?

I know you can set the badge by using:

[UIApplication sharedApplication].applicationIconBadgeNumber = 开发者_JAVA技巧somenumber;

However, this would need to work in the background for it to be able to stay updated. However, there's a 10-minute restriction for backgrounded apps. I'm thinking it has something to do with push notifications, but I don't know how that would work exactly.

Any ideas?


I'm setting a bounty on this. If possible, I would like a detailed step-by-step process of how to set up my webserver to handle these push notifications.


APNS (Apple Push Notification Services) has an option of showing a notification with just a badge (no alert, no sound). You can specify it in the payload. That is how the badge can be updated.

You can have a server send out the message to the user or use local notifications. But since you want to get the user's weather information, I guess a message from the server would be the way to go.

You can also specify that the app uses background services to get updated location and use this location to get the weather info.

Here are a few good references. Once you get the hang of it, its actually pretty easy rolling out your own server/client

  1. http://blog.boxedice.com/2009/07/10/how-to-build-an-apple-push-notification-provider-server-tutorial/

  2. http://code.google.com/p/apns-php/

  3. http://www.easyapns.com/


The 73 here, is normally how you'd see the amount of messages related to the app there are waiting for you.

I assume you can set & reset that number, so they just push an update to you, saying you have 73 in-app messages waiting for you, and they abuse that mechanism to display the tempreature in farenheit.


You're correct, they're doing it through APNS (Apple PUSH Notification Service). It's pretty complicated to set up, but google "iphone APNS" and you'll find much better guides than what I could whip up off the top of my head. Here's the one I used to get out service working. It does a good job of walking through the process step by step.

Once you get it set up, you'll want to pass along a "badge" count with your APNS notification. The documentation for how to do that is here.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜