Problems receiving push in app

I’m getting an error when receiving a push notification when the app is running:

Success: 200

{“message”: “unknown error”}

message: unknown error

Details:

I am building an app that sends a push notification when ever there is an update to a message stream.  Using Coronium, I can successfully send the message through pushbots and it shows as a badge on the app icon and in the notifications window on the device (so far, so good!).

In app is when I get the error (above).  Using mod_pushbots (v1.1), the device is registered and the device token is recorded (we know this is working since we can get notifications outside the app).

Server Pushbots call (using Coronium 1.93).
device is retrieved from a database.  All of this works when the app is closed.

... local device = answer.result.deviceToken coronium.push.to( device, coronium.IOS, "You have received a new Txtpire message", "+1", "beep.caf")

As I said, the problem is receiving the messages when the app is running.  When I first start the app, it will run the refresh once automatically and again for any notifications that were received previously.  I can see the error messages through the debug console via xcode/device, but the Runtime listener isn’t called
What I want to happen is that refresh is called when a new push is received.  Right now that isn’t happening.

main.lua (setup the initial connection with pushbots)

local pushbots = require("mod\_pushbots") local notifications = require( "plugin.notifications" )   notifications.registerForPushNotifications() local function notificationListener( event )   if event.type == "remoteRegistration" then     -- This device has just been registered for push notifications.     -- Store the Registration ID that was assigned to this application.     deviceToken = event.token     --store the token     UserInfo.deviceToken = deviceToken     ------------------------------------------------------------     -- PUSHBOTS REGISTRATION     ------------------------------------------------------------     pushbots:registerDevice( deviceToken, pushbots.NIL, function(e)        if not e.error then         if e.code == 200 then           pushbots:clearBadgeCount( deviceToken )         end       else         native.showAlert( "Pushbots", e.error, { "OK" } )       end     end)     ------------------------------------------------------------   else     -- A push notification has just been received. Print it to the log.     print("### --- Notification Event ---")      --get token     deviceToken = UserInfo.deviceToken   end end Runtime:addEventListener( "notification", notificationListener ) pushbots:init( PushBotAppID )  -- PushBots App ID   pushbots.showStatus = true -- for debuging   pushbots.showAlert = true   pushbots.showJSON = true

The runtime event listener is canceled before leaving main so that it won’t be a problem in messages

message.lua (for receiving notification that there is an update):

local notifications = require( "plugin.notifications" )   notifications.registerForPushNotifications() local refresh= function(event)    print("### --- Notification Event ---")   if event then      print("Event type", event.type) end    -- Reset badge count to 0    pushbots:clearBadgeCount( UserInfo.deviceToken )    counter = counter +1    --mark opened    pushbots:pushOpened()    tempmessage.text = tostring(counter).." push received"    if event then     local beep = audio.loadSound("beep.caf")     audio.play(beep)    end end refresh() Runtime:addEventListener( "notification", refresh )

build.settings and config.lua are correct according to current Corona documentation:
 

-- build.settings plugins =   {     -- Push notifications     ["plugin.notifications"]=     {     publisherId = "com.coronalabs"     }, } -- config.lua     -- Push notifications     notification =     {        iphone =         {           types = { "badge", "sound", "alert" }         }, }

Any suggestions? Ideas??

Hi Brian,

I’m a tad confused. Are you using both Coronium client module and PushBot module in the same app?

Additionally, it has been my experience in the past that alerts are not “announced” if you already have the app open (no need to get your attention), but I am not sure if this is the expected functionality for the SDK.

Furthermore, once the message request is sent from Coronium (or mod_pushbots), it’s out of my hands. At that point its up to PushBots, Apple, Google, Microsoft, and CoronaSDK to make sure your push message is routed and consumed.

I will take a look at the code and see if anything pops out, but if you’re getting a success response when sending, it’s somewhere else in the code or structure.

Cheers.

Yes, Chris, I am using both mod_coronium client and mod_pushbot modules in the same app.

I am using the mod_pushbots to register the device with Pushbots and clear badges/opens.  
I’ve used mod_coronium for talking to Coronium server.

All pushes are done from the Coronium server using coronium.push.to command.

That’s what I was seeing: that alerts are not announced when you are already in the app.  I was hoping you had a different experience.

I will switch to a polling mechanism instead to see if there has been an update to the database.  

Thank you!

Not sure if it’s helpful, but here is the last example posted:

https://bitbucket.org/develephant/mod_pushbots/src/5fc86d325802f10b4a89ed0379236c6dc0a81f42/example/main.lua?at=default&fileviewer=file-view-default

I’m almost positive I had solved this with a work-around for an unrelated test. I’ll dig around.

Cheers.

Hi Brian,

I’m a tad confused. Are you using both Coronium client module and PushBot module in the same app?

Additionally, it has been my experience in the past that alerts are not “announced” if you already have the app open (no need to get your attention), but I am not sure if this is the expected functionality for the SDK.

Furthermore, once the message request is sent from Coronium (or mod_pushbots), it’s out of my hands. At that point its up to PushBots, Apple, Google, Microsoft, and CoronaSDK to make sure your push message is routed and consumed.

I will take a look at the code and see if anything pops out, but if you’re getting a success response when sending, it’s somewhere else in the code or structure.

Cheers.

Yes, Chris, I am using both mod_coronium client and mod_pushbot modules in the same app.

I am using the mod_pushbots to register the device with Pushbots and clear badges/opens.  
I’ve used mod_coronium for talking to Coronium server.

All pushes are done from the Coronium server using coronium.push.to command.

That’s what I was seeing: that alerts are not announced when you are already in the app.  I was hoping you had a different experience.

I will switch to a polling mechanism instead to see if there has been an update to the database.  

Thank you!

Not sure if it’s helpful, but here is the last example posted:

https://bitbucket.org/develephant/mod_pushbots/src/5fc86d325802f10b4a89ed0379236c6dc0a81f42/example/main.lua?at=default&fileviewer=file-view-default

I’m almost positive I had solved this with a work-around for an unrelated test. I’ll dig around.

Cheers.