Reputation: 7358
I'm looking to make my app more responsive by having it automatically download some data (around 10KB) when it receives a notification. My two options (I think) are:
If it's going to be 2, can I do that? Can it be done when the app isn't already running in the background or foreground?
For some updates I'd like to show a notification to the user. Can this be done in the same notification, or do I need to push another one?
Any similar info about iOS much appreciated, but not essential for answering the question!
Upvotes: 0
Views: 1690
Reputation: 394016
When using Google Cloud Messaging you create a broadcast receiver which receives the GCM push notification. The broadcast receiver can either handle the notification on its own or start an intent service (which is better suited for your logic that downloads data from the server, since it runs on a separate thread, and doesn't block the main GUI thread). You can display a notification and download data from your server as a result of the same notification.
Upvotes: 1
Reputation: 371
Look into BroadcastReceiver, once registered you can create a listener inside of your activity that will be called once the notification has been received.
Upvotes: 1