Issues with Push notifications Latests versions of Corona

Hi,

It seems that push notifications doesn’t work anymore on my apps (using corona > 1100 at least)

I’ve the same code (for a quite long time) to process my notifications :

local launchArgs = ... local function onNotification( event ) native.showAlert( "remote", json.encode( launchArgs ), { "OK" } ) end Runtime:addEventListener( "notification", onNotification )

And now nothing is fired. My certificates are up to date, and on old versions of my app, this very same code works.

So i think this could be due to recent changes on corona (like corona cloud…)

Any ideas ?

Hey, @Sunny, which daily build did you use?  I’d like to mention that a device build with push notification worked on iOS fine when built with daily build 1114.  I installed a device build on a cleanly wiped iPod5 yesterday, and it prompted me if I want to receive push notifications from the app the first time I launched the app – and it’s working as expected.

Naomi

Edit:  Woops, I just realized this thread is under Corona Cloud sub-forum.   Maybe something is broken with Corona Cloud?  My push notification implementation does not involve Corona Cloud…

Hi @naomi,

thanks for your reply.you’re right about the subject, don’t want to use corona cloud
I don’t have my computer right now.
I’m going to try with a wiped iphone to make a test.

Cloud and Corona SDK are separate when it comes to things like that.  Corona Cloud is a push sender that you can use your Corona SDK app to register with to receive push notifications. 

launchArgs will only be set if you have received a push notification and your app is not launched.  You should not get a “remote” notification event in this case as launchArgs has the information.   If your app is backgrounded you should get a notification “remote” event.  Are you sure you want to check your launchArgs inside the event handler and not in your main.lua’s main chunk?

Ok thank you both,

I just tried with a different iphone, and everything seems fine.

I’m sorry for your time lost !

thank you again !

Glad to hear it worked for you.

Naomi

I am having troubles with this. If my app is not active or backgrounded (I understand iOS has 5 states of an app), I do receive the push message but when starting the app, I do not get actions for the remote event (for example a native.showAlert or setting badgenumber) 

[lua]–This native popup should show when the app opens / is open and the app was active, inactive, in the background or suspended?

    elseif event.type == “remote” then

        native.showAlert( _G.invitation, event.alert, { “Ok”} )

        native.setProperty( “applicationIconBadgeNumber”, 0 )

    end

[/lua]

However if I look in my iOS messagecenter and tap on the received push message, the app does start / get active and shows a native.showAlert. But you can’t expect that all users enter the app via the push message.

I am using the example in main.lua of http://www.coronalabs.com/blog/2011/12/21/push-notifications-for-ios-in-corona-sdk/ 

So how to let event.type == “remote” do stuff when the app starts (not via tapping on the received pushmessage)?
Or is this just not possible?

This is quite confusing and I’ll try to make sense of this.

Your app can be either

a) not in memory.  That is someone killed it, or it hasn’t started since the last reboot. 

b) in memory but backgrounded. 

c) Active in the foreground.

If you’re active in the foreground, your app should get a notification event of type “remote”.

If your app is backgrounded and you interact with a push notification (swiping the lock while it’s on the lock screen, tapping the notification in the notification center), the OS will bring your app to the foreground and you will get a “remote” event.

If your app is not running and needs cold started and you start it by interacting with the push message, your launchArguments will be set and you will not get a notification event.

If your app is not running and you start it by tapping on it’s icon and not by interacting with a notification, you will not get any notification event or any launch arguments.

Thx Rob,

That’s clear. I make a server interaction than later to show messages when app is not started via the notification. This also is necessary to set the right badgenumber.

Hey, @Sunny, which daily build did you use?  I’d like to mention that a device build with push notification worked on iOS fine when built with daily build 1114.  I installed a device build on a cleanly wiped iPod5 yesterday, and it prompted me if I want to receive push notifications from the app the first time I launched the app – and it’s working as expected.

Naomi

Edit:  Woops, I just realized this thread is under Corona Cloud sub-forum.   Maybe something is broken with Corona Cloud?  My push notification implementation does not involve Corona Cloud…

Hi @naomi,

thanks for your reply.you’re right about the subject, don’t want to use corona cloud
I don’t have my computer right now.
I’m going to try with a wiped iphone to make a test.

Cloud and Corona SDK are separate when it comes to things like that.  Corona Cloud is a push sender that you can use your Corona SDK app to register with to receive push notifications. 

launchArgs will only be set if you have received a push notification and your app is not launched.  You should not get a “remote” notification event in this case as launchArgs has the information.   If your app is backgrounded you should get a notification “remote” event.  Are you sure you want to check your launchArgs inside the event handler and not in your main.lua’s main chunk?

Ok thank you both,

I just tried with a different iphone, and everything seems fine.

I’m sorry for your time lost !

thank you again !

Glad to hear it worked for you.

Naomi

I am having troubles with this. If my app is not active or backgrounded (I understand iOS has 5 states of an app), I do receive the push message but when starting the app, I do not get actions for the remote event (for example a native.showAlert or setting badgenumber) 

[lua]–This native popup should show when the app opens / is open and the app was active, inactive, in the background or suspended?

    elseif event.type == “remote” then

        native.showAlert( _G.invitation, event.alert, { “Ok”} )

        native.setProperty( “applicationIconBadgeNumber”, 0 )

    end

[/lua]

However if I look in my iOS messagecenter and tap on the received push message, the app does start / get active and shows a native.showAlert. But you can’t expect that all users enter the app via the push message.

I am using the example in main.lua of http://www.coronalabs.com/blog/2011/12/21/push-notifications-for-ios-in-corona-sdk/ 

So how to let event.type == “remote” do stuff when the app starts (not via tapping on the received pushmessage)?
Or is this just not possible?

This is quite confusing and I’ll try to make sense of this.

Your app can be either

a) not in memory.  That is someone killed it, or it hasn’t started since the last reboot. 

b) in memory but backgrounded. 

c) Active in the foreground.

If you’re active in the foreground, your app should get a notification event of type “remote”.

If your app is backgrounded and you interact with a push notification (swiping the lock while it’s on the lock screen, tapping the notification in the notification center), the OS will bring your app to the foreground and you will get a “remote” event.

If your app is not running and needs cold started and you start it by interacting with the push message, your launchArguments will be set and you will not get a notification event.

If your app is not running and you start it by tapping on it’s icon and not by interacting with a notification, you will not get any notification event or any launch arguments.

Thx Rob,

That’s clear. I make a server interaction than later to show messages when app is not started via the notification. This also is necessary to set the right badgenumber.