1

What is the best way to enable Push Notifications in AOSP?

- One possible way is to use custom Service which opens a persistent websocket connection.

According to the comment in the answer in this question they used Parse.com PPNS push service. It is an option but it creates an always on PushService. I don't think it is battery efficient.

- Other option is to add Google Play Services into the AOSP ROM.

After Android 4.0.3, devices don't need Google Account set-up to get push notifications. But the devices should have GoogleServicesFramework to be installed at least.

When we include all Google Apps into the ROM, it enables push notifications. Google Apps package includes lots of Google APKs.

Which ones are required for push notification?

And is it legal to just add Google applications into the AOSP built?

Community
  • 1
  • 1
tasomaniac
  • 10,234
  • 6
  • 52
  • 84
  • I think its illegal to include Google apps by you, you need to have a valid license from Google to include google apps. maybe you will get something like this if you do :) http://gizmodo.com/5367420/google-threatens-cyanogen-android-hacker-with-cease-and-desist – nandeesh Sep 30 '14 at 04:54
  • I was suspecting that it would be illegal. So, what are the other ways to do it then? – tasomaniac Sep 30 '14 at 05:23
  • I think even the google push service keeps an always on connection, so any push service will affect battery life the same way. so you can use parse.com – nandeesh Sep 30 '14 at 05:30

2 Answers2

3

create a lightweight background service that listens to network change actions, and in the service send any ip address change of devices to push server. You will also need a unique identifier for each device, may be mac-address or some other hw UUID. Push server needs to maintain a mapping of registered clients, their uuid, and ip address.

This background service can bind to network socket and listen for connections coming in from push server. There will be no persistent connections, just a lightweight service/daemon running in background.

For power efficient way of handling this service, please take a look at Android L JobScheduling. This SO question answer can give you some ideas. You may need to handle socket (re)binding as needed.

This solution can work if you are ok with slight delay in push notifications. Push server needs to retry connections, you may use some heuristics like letting the device inform server of its background-service running state(s).

You will need to have this service installed/running on all your devices. Once a message is received on the device, it is easy to make it look like a regular push notification.

Community
  • 1
  • 1
ashoke
  • 6,441
  • 2
  • 26
  • 25
1

It is illegal to include Google libraries within an AOSP build without obtaining a proper license.

This makes it impossible to send notifications with Google Cloud Messaging on AOSP devices.

What you could do instead is send notifications to devices without using GCM. You could use Pushy (https://pushy.me/) which is a highly-reliable push gateway for Android apps that works independently from GCM, using its own background MQTT connection.

Full disclosure: I founded Pushy.

Elad Nava
  • 7,746
  • 2
  • 41
  • 61