ekospinach / foursquared

foursquared source | built for android
Apache License 2.0
0 stars 0 forks source link

Push Notifications #107

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Provide up to the minute user information to the user by using push 
notifications. This will require either gtalk hacks or an android based push 
notifications infrastructure provided by Google.

Original issue reported on code.google.com by jlapenna on 21 Sep 2009 at 3:21

GoogleCodeExporter commented 9 years ago
http://joelapenna.com/blog/2009/07/android-foursquare-and-push

How to get push notifications on Android.
As we all are aware its possible to run apps in the background in Android. The 
way 
push notifications work for the google apps like gmail and gtalk are by way of 
TCP 
connections with long TTLs. This allows the phone to wake up intermittently as 
the 
gsm radio will do (on the measure of microseconds) to see if new data has 
arrived on 
the wire. This implementation though, requires its own backend and for each 
service 
doing it, we'd be draining the battery even further...

Other work on Android Push:

Push services: Implementing persistent mobile TCP connections
android-random project: KeepAliveService.java
XMPP/Jabber is even worse. Not only is xmpp/jabber a very chatty protocol, but 
as it 
works with one long xml stream, the disconnected nature of a cell phone does 
not jive 
well with it... holding an open xmpp connection is probably a very bad idea.

So where does this leave us with push notifications on Android if anything push 
we do 
is going to eat the battery and cause the user to uninstall the app?

One option would be to send periodic position updates based on some limiter 
(the API 
only has a radius accuracy of no less than a mile. We wouldn't have to wake up 
all 
that frequently for the common case of people don't drive around during night 
time 
activities). Knowing this, most of the work can be done on the backend to 
calculate 
"interesting things," and for notifications, we can send the response over 
gtalk. 
Specifically gtalk because most Android phones already have that previously 
mentioned 
long-lived tcp session that we can piggy back on. The message could be 
something 
along the lines of:

<a 
href="foursquare://com.playfoursquare.api.NotificationsAuthority/notification/12
345?
click=user">Mike M.</a> is hanging out at <a 
href="foursquare://com.playfoursquare.api.NotificationsAuthority/notification/no
tific
ation/12345?click=venue">Mike's Bar and Grill</a>.

Users clicking on the link would be directed to the android foursquare app, 
where we 
could display awesome information.

I'd have to try this out to see if it actually works and how an android app 
would 
register as a global URI handler but it should be do-able.

Original comment by jlapenna on 21 Sep 2009 at 3:22

GoogleCodeExporter commented 9 years ago

Original comment by jlapenna on 5 Oct 2009 at 8:36

GoogleCodeExporter commented 9 years ago
http://android-developers.blogspot.com/2010/05/android-cloud-to-device-messaging
.html
"Here are a few basic things to know about C2DM:

It requires Android 2.2; C2DM uses Google services which are present on any 
device running the Android Market.
It uses existing connections for Google services. This requires the users to 
sign into their Google account on Android.
It allows 3rd party servers to send lightweight data messages to their apps. 
The C2DM service is not designed for pushing a lot of user content; rather it 
should be used like a “tickle”, to tell the app that there is new data on 
the server, so the app can fetch it.
An application doesn’t need to be running to receive data messages. The 
system will wake up the app via an Intent broadcast when the the data message 
arrives, so long as the app is set up with the proper Intent Receiver and 
permissions.
No user interface is required for receiving the data messages. The app can post 
a notification (or display other UI) if it desires.
It’s easy to use the C2DM API. Here is how it works:

To enable C2DM, an application on the device registers with Google and get a 
registration ID, and sends the ID to its server.
When the server needs to push a message to the app on the device, it posts the 
message via HTTP to Google’s C2DM servers.
The C2DM servers route the message to the device, and an Intent broadcast is 
sent to the app.
The app is woken up to process the message in its Intent Receiver.
The app can unregister with C2DM when the user no longer wants messages to be 
pushed to it."
Looks like the best solution.

Original comment by benedikt...@gmail.com on 8 Jun 2010 at 7:42

GoogleCodeExporter commented 9 years ago
It looks like the latest update added push using c2dm: 
https://market.android.com/details?id=com.joelapenna.foursquared

Original comment by joe.lencioni on 14 Feb 2011 at 1:55