Push notifications

>> we’re looking forward to the Project Gluon work. I hope that is going well.

It’s doing well so far. We have at least 2 developers (that I know) working on plugins, implementing 3rd party features that most of the community has been wanting for a while now. This will be our trial run to work out whatever kinks are in our framework and on how to distribute plugins. Expect to hear more about this in January.

>> You mentioned you’d be working on Android push notifications again this week. Have you been able to get back to it this week?

Yes! I started working on it again last Monday. I’m trying to get it done by the end of this week. I’ve also been working on a sample app which will push a notification to itself via GCM (Google Cloud Messaging). So, it will demonstrate both sending and receiving notifications on Android. It will also indicate what needs to be in your “build.settings” and “config.lua” files.

In the mean-time, I recommend that you have a look at the following forum post which tells you how to add your own custom notification icon to your Corona project. You can already test this today with local notifications on Android. These same icon files will be used for push notifications too.
http://developer.coronalabs.com/forum/2012/12/05/custom-icon-local-notifications-android#comment-134069
[import]uid: 32256 topic_id: 31525 reply_id: 135942[/import]

Fantastic! Great news all around.

Thank you [import]uid: 25108 topic_id: 31525 reply_id: 135949[/import]

Hi Joshua, we’re looking forward to the Project Gluon work. I hope that is going well.

You mentioned you’d be working on Android push notifications again this week. Have you been able to get back to it this week? Do you have an update/estimate?

Thank you [import]uid: 25108 topic_id: 31525 reply_id: 135781[/import]

MindFeud 4.0.2 and Quopples 1.0.4 was released on Google Play yesterday, leveraging the new Push Notifications API. Our servers were already set up for using GCM, and with Joshuas sample project it took somewhere around 3 minutes + build and upload time to get it live.

Thanks, very happy to get this out at last. And props to Joshua for a very streamlined integration, we only needed a few lines in the config and build settings, the rest just used our existing ios push implementation. [import]uid: 21746 topic_id: 31525 reply_id: 136185[/import]

Que?

Push notification can be done now… Whers this info at

Nevermind… Just checked the daily builds

Joshua quick - THANKYOU
[import]uid: 55582 topic_id: 31525 reply_id: 136196[/import]

@DavidRangel: Am I to understand that Josh is the only person who can make Push Notifications on Android and he has been swamped with other work for like a year?

Judging from this, Corona seems understaffed. Can you clarify the situation and explain what measures Corona management is taking to prevent vital features from being pushed back for months and months?
[import]uid: 73434 topic_id: 31525 reply_id: 136198[/import]

Olav.morkrid - You are right in that we have indeed been swamped with a bunch of other things (Android and other platforms) recently :slight_smile:
But let me clear up 2 things:

  1. Saying that we put off push notifications for “like a year” is not correct - although I completely understand that this is what it seems like externally. And we have no one to blame for that other than ourselves. We are now being more careful about what we promise. We will now underpromise and overdeliver. That has not been the case in the past.

  2. While Josh is not the only person that can do these things, he is definitely our lead Android developer. Regardless, this is what we are doing to address issues around this: we are hiring!
    http://www.coronalabs.com/about/jobs/
    Very specifically, we are aggressively looking for great Core Engineers (http://www.coronalabs.com/about/jobs/core-engineer/). If you know anyone, please let us know!

David

[import]uid: 10668 topic_id: 31525 reply_id: 136223[/import]

Everyone,

Yes, the newest daily build supports Google push notifications. Have a look at the new sample app “Notifications/GooglePushNotifications” that is included with the Corona SDK for instructions on how to set it up and use it. That sample app demonstrates this new feature by sending a push notification to itself.

It should be really easy to set up, just as Haakon has noted. Just follow the instructions that you see in the sample app’s “main.lua” and “config.lua” file.

Also note that push notifications will only work via Google Play. That means that the Google Play app must be installed on your Android device and set up with an account. This also means this feature will not work on Kindle or Nook devices… or any other app marketplaces.

Expect a blog post about this feature to come out later this week. [import]uid: 32256 topic_id: 31525 reply_id: 136287[/import]

>> we’re looking forward to the Project Gluon work. I hope that is going well.

It’s doing well so far. We have at least 2 developers (that I know) working on plugins, implementing 3rd party features that most of the community has been wanting for a while now. This will be our trial run to work out whatever kinks are in our framework and on how to distribute plugins. Expect to hear more about this in January.

>> You mentioned you’d be working on Android push notifications again this week. Have you been able to get back to it this week?

Yes! I started working on it again last Monday. I’m trying to get it done by the end of this week. I’ve also been working on a sample app which will push a notification to itself via GCM (Google Cloud Messaging). So, it will demonstrate both sending and receiving notifications on Android. It will also indicate what needs to be in your “build.settings” and “config.lua” files.

In the mean-time, I recommend that you have a look at the following forum post which tells you how to add your own custom notification icon to your Corona project. You can already test this today with local notifications on Android. These same icon files will be used for push notifications too.
http://developer.coronalabs.com/forum/2012/12/05/custom-icon-local-notifications-android#comment-134069
[import]uid: 32256 topic_id: 31525 reply_id: 135942[/import]

Fantastic! Great news all around.

Thank you [import]uid: 25108 topic_id: 31525 reply_id: 135949[/import]

@DavidRangel: Finally! Well, it works for all I can tell. This was a nice Christmas present indeed. And it’s good to see you are open about your hindsight. Let’s hope stuff like this never happens again.

One question: The example code includes “custom” data in the push. Does this mean that Corona now also supports this, for both iPhone and Corona? If so, what is the Lua code to fetch the custom data?
[import]uid: 73434 topic_id: 31525 reply_id: 136354[/import]

@Olav: It works just as intended. I changed a C2DM c# asp.net page to push using gcm and have been sending pushes to my registered test devices since christmas morning… [import]uid: 55582 topic_id: 31525 reply_id: 136355[/import]

@DavidRangel @Joshua_Quick: Well, I have run into one problem:

If you get a push OUTSIDE the app, and click the push to go into the app, both Android and iPhone get onNotification(event) with event.type = “remote”.

But if you get a push INSIDE the app, only iPhone get onNotification(event) with event.type = “remote”, while Android gets nothing.

The consequence of this is that Android players who are inside the app will not get invitations, chat messages, etc. (Not until they suspend the app, and re-enter the app at a later time.)

How soon can you have a fix ready for this?

PS! On a side note: Does the @ character in this forum trigger a notification? If so, how do I notify people with a space character in their username? [import]uid: 73434 topic_id: 31525 reply_id: 136356[/import]

Are you talking about the forum sending an email that there is a followup post?

If so, I don’t believe the @ sign does anything, other than habit from using it in other services. Once you reply to a thread, you are subscribed to it and if your settings are setup correctly you will get emails when there are replies.

I’ll make sure the team hops on to answer these questions about the payload and the event’s being generated.

[import]uid: 199310 topic_id: 31525 reply_id: 136367[/import]

>> The example code includes “custom” data in the push. Does this mean that Corona now also supports this, for both iPhone and Corona? If so, what is the Lua code to fetch the custom data?

“custom” data is definitely supported on Android. If you view the Android log, notice that we print all of the custom data’s content to the log. You can access the custom data via “event.custom” in the notification event provided by its onNotification Lua listener or via the app’s launch arguments. Also note that if you do not provide any custom data, then “event.custom” will be an empty table.

In my opinion, “custom” data is absolutely necessary for push notifications because it is your only means of identifying what the notification is for. Especially if you localize your alert messages.

>> If you get a push INSIDE the app, only iPhone get onNotification(event) with event.type = “remote”, while Android gets nothing.

Yes, this is a known behavioral inconsistency between iOS and Android. Corona does correctly receive the push notification on Android while your app is in the foreground, but it goes straight to the status bar and does not call the notification Lua listener. The notification Lua listener is only called on Android when the end-user taps on the notification on the status bar.

I’ll look into making Android match the iOS behavior this week.
[import]uid: 32256 topic_id: 31525 reply_id: 136390[/import]

@Josh: Great! Keep us posted on the Android listener.

Any plans for custom data support on iPhone?
[import]uid: 73434 topic_id: 31525 reply_id: 136399[/import]

It was my understanding that we do support custom data from push notifications on iOS. According to our internal revision history, we’ve added support 7 months ago. Roughly 5 months after we added push notification support on iOS.

Have you tried testing this for yourself? Is it not working for you? [import]uid: 32256 topic_id: 31525 reply_id: 136405[/import]

Everyone,

We’ve modified push and local notifications on Android to raise a notification event in Lua immediately if the Corona app is active and in the foreground. This is to match iOS’ behavior. Please note that the notification will still be posted to the status bar because we have noticed that iOS does this as well.

The above change will be made available in daily build #994, tomorrow. [import]uid: 32256 topic_id: 31525 reply_id: 136417[/import]

@Josh: I for one cannot see any custom data in iOS pushes. My payload is arranged like this (PHP):

[php]
$body[“aps”] = array(
“sound” => “default”,
“alert” => $message,
“custom” => array(
“hello” => “Hello”,
),
);
$body[“world”] = “World”; // Suggested by some forum posting, but does not work either
[/php]

The notification arrives on iPhone like this:

[lua]notification = {
type = “remote”,
name = “notification”,
custom = {
},
sound = “default”,
alert = “This is your wake-up call”,
applicationState = “inactive”, – doesn’t work for active state either
}[/lua]

PS! Looking forward to the notification fix in the next build. [import]uid: 73434 topic_id: 31525 reply_id: 136435[/import]

Olav,

It looks like you are sending the custom data correctly to me. The only restriction we have on custom data is that it must be a table. At least at the root level… and you’re sending it as a table.

I’ll have someone on my end investigate this. Also, if you don’t mind, I suggest that you write this up as a bug report so that it’ll get on our tech-support queue and so that you’ll be notified via e-mail when it gets resolved. You can do so by clicking the “Report a Bug” link at the top of this web page.

In the mean-time, the “event.custom” data definitely works on Android. I’ve tested this for myself. If you look at sample app “Notifications/GooglePushNotifications” that is included with the Corona SDK, notice that it sends all kinds of data in one shot (ie: table, boolean, number, string, nested array, nested table, mixed types within a table/array). We did this to demonstrate its capabilities and for our own testing. So, please feel free to use custom data on Android.

By the way, daily build #944 is available now. This version will raise the notification event immediately if your Android app is active and in the foreground, just like iOS. [import]uid: 32256 topic_id: 31525 reply_id: 136473[/import]