Corundum Push Help

Hey Chris,

I’ve been developing an app based on Coronium and everything has been so easy! Thanks heaps.

But today I hit a wall. I’m trying to figure out the push notifications and I can’t get my device to register. I’ve signed up with PushBots and saved the key and secret in the admin panel.

Here is my main.lua code 

local composer = require( "composer" ) local scene = composer.newScene() local notifications = require( "plugin.notifications" ) notifications.registerForPushNotifications() local coronium = require( "mod\_coronium" ) coronium:init( { appId = "my.domain.com", apiKey = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" } ) ..... if (launchArgs and launchArgs.notification) then end local function notificationListener( event ) ------- CLEAR BADGE NUMBER ON APPLE if device.isApple and badge ~= 0 then native.setProperty( "applicationIconBadgeNumber", 0 ) end ------- REGISTER DEVICE WITH PUSHBOTS if ( event.type == "remoteRegistration" ) then local answer = coronium.push.registerDevice( event.token, coronium.IOS ) if not answer.error then coronium.log( "Device registered" ) end ------- RECEIVE LOCAL NOTIFICATION elseif ( event.type == "local" ) then if (event.custom) then if (event.custom.msgTitle) then msgTitle = event.custom.msgTitle end end --handle the local notification native.showAlert( msgTitle, event.alert, { "OK" } ) ------- RECEIVE PUSH NOTIFICATION elseif ( event.type == "remote" ) then if (event.custom) then if (event.custom.msgTitle) then msgTitle = event.custom.msgTitle end end --handle the push notification native.showAlert( msgTitle, event.alert, { "OK" } ) end end Runtime:addEventListener( "notification", notificationListener )

I get to the “registerDevice” with a token, and then just nothing. No error, no output of any kind.

I tried to find the answers on Google and I found another thread where someone was using mod_push, but from what I can tell, that’s no longer maintained?

I’m using mod_coronium v1.92.5, my coronium server is 1.92 and I’m building with corona DB 2016.2850

Any ideas or suggestions? Or am I better off just waiting for Coronium 2?

Cheers,

Brad

Hi,

This comes up every so often, generally its just a matter of waiting for certs, etc to be updated in all the right places. You can also contact PushBots directly, they will be more than happy to make sure you’re running.

help@pushbots.com

Cheers.

Everything on their end is fine according to them.

I managed to get it working by stripping it back to bare bones.

 local body = json.encode( { token = "deviceToken", platform = platform, tags = tags } ) local headers = { ["X-PUSHBOTS-APPID"] = "xxx", ["X-PUSHBOTS-SECRET"] = "xxx", ["Content-Type"] = "application/json" } local params={} params.body = body params.headers = headers local function networkListener( event ) if ( event.isError ) then print( "Network error: ", event.response ) else print ( "RESPONSE: " .. event.response ) end end local answer = network.request( 'https://api.pushbots.com/deviceToken', "PUT", networkListener, params )

I did a test and coronium.push.registerDevice does not seem to work.

print (coronium.IOS) -> returns nil

This may be the issue?

Hi,

This comes up every so often, generally its just a matter of waiting for certs, etc to be updated in all the right places. You can also contact PushBots directly, they will be more than happy to make sure you’re running.

help@pushbots.com

Cheers.

Everything on their end is fine according to them.

I managed to get it working by stripping it back to bare bones.

 local body = json.encode( { token = "deviceToken", platform = platform, tags = tags } ) local headers = { ["X-PUSHBOTS-APPID"] = "xxx", ["X-PUSHBOTS-SECRET"] = "xxx", ["Content-Type"] = "application/json" } local params={} params.body = body params.headers = headers local function networkListener( event ) if ( event.isError ) then print( "Network error: ", event.response ) else print ( "RESPONSE: " .. event.response ) end end local answer = network.request( 'https://api.pushbots.com/deviceToken', "PUT", networkListener, params )

I did a test and coronium.push.registerDevice does not seem to work.

print (coronium.IOS) -> returns nil

This may be the issue?