Android push notification gets through but nothing is displayed

Hey forum,

I am sending a push notification from a PHP-script to my Android device and the device receives the notification. So far so good. Also when you start the application from the push notification everything at the corona side gets works as it should.

The problem is how the push notification is displayed. All I see in the notification center on my device is the corona_statusbar_icon_default icon and the name of the Application.

No message is shown, no title, no subtitle, nothing. Only those two items. 

Do I have to enable something in Corona to have that displayed there or at the PHP-side of the notification?

I have tried this with the example app and encountered the same issue.

This is my php code:

 $msg = array ( 'message' =\> 'here is a message. message', 'title' =\> 'This is a title. title', 'subtitle' =\> 'This is a subtitle. subtitle', 'tickerText' =\> 'Ticker text here...Ticker text here...Ticker text here' ); $url = 'https://android.googleapis.com/gcm/send'; $fields = array( 'registration\_ids' =\> $androidUsers, 'data' =\> $msg ); $headers = array( 'Authorization: key=' . $apiKey, 'Content-Type: application/json' ); // Open connection $ch = curl\_init(); // Set the url, number of POST vars, POST data curl\_setopt( $ch, CURLOPT\_URL, $url ); curl\_setopt( $ch, CURLOPT\_POST, true ); curl\_setopt( $ch, CURLOPT\_HTTPHEADER, $headers); curl\_setopt( $ch, CURLOPT\_RETURNTRANSFER, true ); curl\_setopt( $ch, CURLOPT\_POSTFIELDS, json\_encode( $fields ) ); // Execute post $result = curl\_exec($ch); // Close connection curl\_close($ch);

The Corona code is the sample project: GooglePushNotifications

The build is CoronaEnterprise.2014.2123

Any solutions?

In sample project “Notifications/GooglePushNotifications”, have a look at the sendNotification() function in the “main.lua”.  There are several comments in there explaining what you need to put in the JSON packet to show a custom “alert” message, play a custom “sound”, and how to add your own “custom” data table.

We also have documentation on how to set this up via the link below.  It will tell you how to override our standard notification icons for Corona Simulator builds and Enterprise builds, because it works differently between the two.

   http://docs.coronalabs.com/guide/events/appNotification/index.html

So, if you want to override the notification icons for Enterprise builds, you need to follow these instructions…

   http://docs.coronalabs.com/guide/events/appNotification/index.html#enterprise-and-android-icons

Thanks Joshua! I found the solution in the samplecode. I must have somehow overlooked this.

I needed to change the tag “message” to “alert” in my php script and now I receive messages with the alert message displayed in the notification center.

In sample project “Notifications/GooglePushNotifications”, have a look at the sendNotification() function in the “main.lua”.  There are several comments in there explaining what you need to put in the JSON packet to show a custom “alert” message, play a custom “sound”, and how to add your own “custom” data table.

We also have documentation on how to set this up via the link below.  It will tell you how to override our standard notification icons for Corona Simulator builds and Enterprise builds, because it works differently between the two.

   http://docs.coronalabs.com/guide/events/appNotification/index.html

So, if you want to override the notification icons for Enterprise builds, you need to follow these instructions…

   http://docs.coronalabs.com/guide/events/appNotification/index.html#enterprise-and-android-icons

Thanks Joshua! I found the solution in the samplecode. I must have somehow overlooked this.

I needed to change the tag “message” to “alert” in my php script and now I receive messages with the alert message displayed in the notification center.