11

I'm writing a system app for a device that has
no Google Play Services nor Google Play Store installed.

I want to implement push notifications.

The device is running Android 4.2.2 and official Google GCM docs say:

A Google account is not a requirement on devices running Android 4.0.4 or higher.

But these docs are related to the new version of GCM which uses Google Play Services (not an option for me)

So I tried using the old, deprecated GCM helper library.
I installed GoogleServicesFramework4.0.x on the device (I can install GSF. but not Google Play Services)

I am now getting the AUTHENTICATION_FAILED error and registrationId is null.
I am guessing this is because no Google account is set up on the device.
Does the deprecated GCM library require Google account?
(My SENDER_ID is correct, I already checked that)


Basically, my question is:
Is it possible to make GCM work without Google account,
using the old, deprecated GCM helper library?

NOTE: I mustn't create Google account on the device (this is a requirement)

If this is not possible, then please suggest another way of implementing push notifications.
(Note that most of the push notifications providers actually use GCM "under the hood" (Urban Airpush, for example), so don't suggest those)

I would like to avoid having to poll server for notifications ("pull notifications") if possible,
thank you.

Eran
  • 387,369
  • 54
  • 702
  • 768
Bojan Radivojevic
  • 717
  • 3
  • 12
  • 23
  • Unfortunately it's not possible. It is a core requirement of GCM/FCM. Consider using an alternative to GCM that works without Google Play Services, Pushy (https://pushy.me/), an independent, reliable push notification gateway. Full disclosure - I am the Founder & CEO at Pushy. – Elad Nava Aug 25 '18 at 09:29

2 Answers2

12

Just prior to the quote you posted (about Google account not being required), you have this :

It requires devices running Android 2.2 or higher that also have the Google Play Store application installed, or or an emulator running Android 2.2 with Google APIs. However, you are not limited to deploying your Android applications through Google Play Store.

Therefore it seems Google Play Store is a must for GCM to work.

Pushy is a paid alternative to GCM that works without Google Play Services. Alternatively, you can develop your own notification service using MQTT or XMPP.

Elad Nava
  • 7,746
  • 2
  • 41
  • 61
Eran
  • 387,369
  • 54
  • 702
  • 768
  • True, but I'm not sure if those docs even apply to the old library. I would like to see more people's opinions on this... – Bojan Radivojevic Jan 24 '14 at 16:10
  • @BojanRadivojevicBomber It applies to the old library. This requirement has been there long before the old library was deprecated. I've been following the GCM docs for a while, so I know. – Eran Jan 24 '14 at 16:27
  • 1
    I ended up using parse.com which implements its own service for Push Notifications instead of realying on GCM – Bojan Radivojevic Jan 27 '14 at 09:24
  • Even though it works in principle, sooner or later the Google Play Services on the phone will become out-of-date. And I'm not sure you can update those without Google Play set up with a Google account. Anyone knows how maybe? – johsin18 Apr 20 '15 at 11:29
8

As an alternative to GCM, you could use MQTT as an open source and popular push notification alternative when Google account and Google Play services are absent on the device. Facebook has used aspects of MQTT in Facebook Messenger.

MQTT implementation requires:

1) an MQTT broker which runs on the server side. This could be something like the mosquitto broker which is Open Source.

2) an MQTT client library which you include in your Android app, enabling your app to connect, subscribe, and publish messages. There are a number of Java options listed at http://mqtt.org/software

3) to come up with a way of uniquely identifying users or devices, and then use that as a topic so that you can individually publish a message to one device. Dale Lane has written a nice guide on this (http://dalelane.co.uk/blog/?p=1599) and there is also a good set of resources about MQTT (https://github.com/mqtt/mqtt.github.io/wiki)

Also the blog post Github sample below provides a practical example to implement MQTT push notification for Android:

http://tokudu.com/post/50024574938/how-to-implement-push-notifications-for-android

https://github.com/tokudu/AndroidPushNotificationsDemo

Ian Pinto
  • 2,199
  • 1
  • 21
  • 24
  • I agree that MQTT is a viable alternative. I wrote an app with MQTT myself and also followed Dale Lanes's example in the first place. Now that there is Eclipse Paho Android I would recommend it, it is newer and more mature. http://www.eclipse.org/paho/clients/android/ – winne2 Aug 12 '16 at 21:33