Push notifications

@Josh: Brilliant! Android now catches the push even from within the app. It’s very reassuring to see you guys handling issues so quickly.

About the “custom” field: Yes, it works on Android. But it never has worked on iPhone (I tried this months ago too). I filed a bug report like you requested. Please keep me updated (here, or in the bug report system if it keeps the reporter updated by e-mail).

[import]uid: 73434 topic_id: 31525 reply_id: 136503[/import]

Yeah, I reported that custom data was missing in ios push notifications almost a year ago, but I guess my score was low already then since nothing was ever done with it… :slight_smile: Hope your karma is better than mine, Olav!

Just a hint to those of you implementing push on Android. We’ve had a RUSH of support tickets since releasing in in MindFeud. There’s nowhere to control push settings per app in the Android OS, so take the time to implement your own in-app settings to allow your users to turn on/off push completely, and the choice between banners only or banner and sound. We’re releasing that tomorrow! :O) [import]uid: 21746 topic_id: 31525 reply_id: 136504[/import]

Olav, Haakon,

The “event.custom” data issue on iOS is being investigated by someone now.
I had a quick look at our bug database and we do indeed have several outstanding bug reports regarding “event.custom” data on iOS. Admittedly, we dropped the ball on this issue because some of us (including me) thought it was already resolved. I apologize for that. In any case, we’re looking into resolving this issue now.
[import]uid: 32256 topic_id: 31525 reply_id: 136506[/import]

Everyone,

We’ve just updated Corona for iOS to support custom data from push notifications. This change will be made available in daily build #995, tomorrow. [import]uid: 32256 topic_id: 31525 reply_id: 136531[/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]

@Josh: I can confirm that the custom fields now work on iPhone. Great work, man!

I have a final question about pushes: Shouldn’t event.badge set the application badge directly? This has never worked. This means the end user never gets any indication that something has happened in the app before he actually goes into the app, and the badge is set manually with native.setProperty(“applicationIconBadgeNumber”, badge), and then it’s sort of too late. If setting the badge directly is a quick fix, I would really appreciate to see it in an upcoming build.
[import]uid: 73434 topic_id: 31525 reply_id: 136666[/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]

>> I can confirm that the custom fields now work on iPhone. Great work, man!

Great to hear! All thanks goes to Perry, our new VP of Engineering. I merely raised the issue and pointed out what needed to be done. :slight_smile:

>> Shouldn’t event.badge set the application badge directly?

Our blog post about iOS remote notifications (see the below link) suggests that it can. I believe you have to add the “badge” setting to your “config.lua” file as described by that blog entry to make this work. If the blog’s instructions still don’t work for you, then I can have someone investigate this late next week.
http://www.coronalabs.com/blog/2011/12/21/push-notifications-for-ios-in-corona-sdk/
[import]uid: 32256 topic_id: 31525 reply_id: 136741[/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]

According to my tests, this is the current status:

  1. iPhone:
  • YES: native.setProperty(“applicationIconBadgeNumber”, badge)
  • NO: event.badge
  1. Android:
  • NO: native.setProperty(“applicationIconBadgeNumber”, badge)
  • NO: event.badge

If you plan to fix this, make sure it works whether the app is running or suspended.

[lua]notification = {
iphone = {
types = {
“badge”, “sound”, “alert”,
},
},
},[/lua]

[php]
$body[“aps”] = array(
“sound” => “default”,
“alert” => $message,
“badge” => 7,
);
[/php]
[import]uid: 73434 topic_id: 31525 reply_id: 136749[/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]