Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google GCM - Not receiving push notifications in android Lollipop

In my android application I use GCM to receive message from my company server.

I wrote the code for c2dm and I followed the instructions for migrating the code to GCM. (http://developer.android.com/google/gcm/c2dm.html)

In android Lollipop (Nexus 9 wifi), the device registers for push notifications and receives the push registration id, but when I send a message from my server, in the device I don't receive any message.

In previous android versions (from 4.0 to 4.4) I haven't any problems.

Do you know of any problems in push notifications of Lollipop?

Thanks

like image 214
TizioIncognito Avatar asked Nov 14 '14 10:11

TizioIncognito


People also ask

What is GCM push notification?

Google Cloud Messaging (GCM) was a mobile notification service developed by Google that enables third-party application developers to send notification data or information from developer-run servers to applications that target the Google Android Operating System, as well as applications or extensions developed for the ...

What is difference between GCM and FCM in Android?

FCM is a cloud platform that provides messages and push notifications for operating systems- ios and Android, and websites as well. Google Cloud Messaging is a messaging service that enables the message transfer from server to clients apps.

Is GCM and FCM same?

Firebase Cloud Messaging (FCM), formerly known as Google Cloud Messaging (GCM), is a cross-platform cloud solution for messages and notifications for Android, iOS, and web applications, which as of June 2022 can be used at no cost.

How do I enable push notifications on Google?

Turn on notifications for Android devicesTap More on the bottom navigation bar and select Settings. Tap Turn on notifications. Tap Notifications. Tap Show notifications.

Why can’t my Android application receive messages from GCM?

Without Google Play, an Android application cannot receive messages from GCM. If you do not yet have the Google Play Store app installed on your device, visit the Google Play web site to download and install Google Play.

What are push notifications in Google ads mobile app?

Enable push notifications in the Google Ads Mobile App to receive relevant updates on performance changes, new features, and actionable recommendations for improving campaign performance, from wherever you are. How to set up push notifications

What is Google Cloud Messaging (GCM)?

Google cloud messaging (GCM) is an Android platform API provided by Google for sending and receiving push notifications to and from an Android application. This is one of the most important arsenal in an Android developer’s armory.

How do I Turn on push notifications on my phone?

How to set up push notifications Turn on notifications for iOS devices Tap Moreon the bottom navigation bar and select Settings. Tap Turn on notifications. Tap Notifications. Tap Allow Notifications. Turn on notifications for Android devices


1 Answers

We encountered the same problem in our office, which is why I stumbled upon your post here. I've tested three separate Nexus 9 devices (WiFi Only), and in each case all of them successfully registered for push...but never receive any notifications that are sent from the server.

The first test I did used our existing android application and server. After this was unsuccessful I downloaded Push Notification Test from the Google Play Store . This worked flawlessly on other devices (Nexus 5...etc), but failed to receive notifications on the Nexus 9.

Just for the sake of a possible issue with the Play Store Test application being out of date, I created a test Android application and server script to see if I could narrow the problem down further. I encountered the same issue. Every device I tested with the exception of the Nexus 9 registered and received push notifications. I tried varying the version of the Google Play Services library in the project (from newest to a few versions back), but that had no effect.

For my last attempt mentioned above I used the GCM demo application found here: GCM Client along with a php script I modified based on another user's code (with keys and reg id's removed obviously):

<?php

$nexus5 = '';
$nexus9 = '';
$nexus9Alt = '';
$registrationIds = array($nexus5,$nexus9,$nexus9Alt);

$apiKey = '';

$msg = array
(
    'message'       => 'Do you know smell what the rock is cooking?',
    'title'         => 'Push Test',
    'subtitle'      => 'This is a subtitle',
    'tickerText'    => 'This is the ticker',
    'vibrate'       => 1,
    'sound'         => 1
);

$fields = array
(
    'registration_ids'  => $registrationIds,
    'data'              => $msg
);

$headers = array
(
    'Authorization: key=' . $apiKey,
    'Content-Type: application/json'
);

$ch = curl_init();
curl_setopt( $ch,CURLOPT_URL, 'https://android.googleapis.com/gcm/send' );
curl_setopt( $ch,CURLOPT_POST, true );
curl_setopt( $ch,CURLOPT_HTTPHEADER, $headers );
curl_setopt( $ch,CURLOPT_RETURNTRANSFER, true );
curl_setopt( $ch,CURLOPT_SSL_VERIFYPEER, false );
curl_setopt( $ch,CURLOPT_POSTFIELDS, json_encode( $fields ) );
$result = curl_exec($ch );
curl_close( $ch );

echo $result;

Update: We updated the three tablets in office to the 5.0.1 OTA, and the tablets still will not receive push notifications. No news from google on these either, but hopefully it will be fixed in the next OTA.

Update: On January 13th we noticed that the Nexus 9's started receiving push notifications. Apparently Google fixed it. The circle is complete.

like image 191
ninehundreds Avatar answered Sep 22 '22 12:09

ninehundreds