App exits immediately with PushWoosh code added

Hello,

I am trying to use PushWoosh in my Android app for the first time. I am using the code from their tutorial at the url http://www.pushwoosh.com/programming-push-notification/corona-sdk-ios-push-notifications/  I added it in the main.lue file which is used in my scene app. Below is the code to my main.lua file. Can anyone tell me if I did something wrong?

I changed my PW_APPLICATION for posting. I also left the launchArgs alone because I don’t know what to change that to if needed. And I have the gotoScene after everything. Should I move this somewhere else in the code?

Thanks!

----------------------------------------------------------------------------------------- -- -- main.lua -- ----------------------------------------------------------------------------------------- local storyboard = require "storyboard" storyboard.FBLoggedIn = "N" storyboard.SoundOn = "Y" local launchArgs = ... local json = require "json" if launchArgs and launchArgs.notification then native.showAlert( "launchArgs", json.encode( launchArgs.notification ), { "OK" } ) end -- notification listener local function onNotification( event ) if event.type == "remoteRegistration" then local DeviceID = event.token local PW\_APPLICATION = "xxxxxxxxxxxxxxx" --use your app id in pushwoosh local PW\_URL = "https://cp.pushwoosh.com/json/1.3/registerDevice" local function networkListener( event ) if ( event.isError ) then --error occurred notify user native.showAlert( "Notification Registration Failed", "An Error Contacting the Server has Occurred. Please try again later from the application settings.", { "OK" } ) else --Registration worked perform any action you like here end end local commands\_json = { ["request"] = { ["application"] = PW\_APPLICATION, ["push\_token"] = DeviceID, ["language"] = system.getPreference("ui", "language"), ["hwid"] = system.getInfo("deviceID"), ["timezone"] = 3600, -- offset in seconds ["device\_type"] = 1 } } local jsonvar = {} jsonvar = json.encode(commands\_json) local post = jsonvar local headers = {} headers["Content-Type"] = "application/json" headers["Accept-Language"] = "en-US" local params = {} params.headers = headers params.body = post network.request ( PW\_URL, "POST", networkListener, params ) end end Runtime:addEventListener( "notification", onNotification ) -- load scenetemplate.lua storyboard.gotoScene( "SceneHome" ) -- Add any objects that should appear on all scenes below (e.g. tab bar, hud, etc.):

check out:

http://docs.coronalabs.com/guide/events/appNotification/index.html

We have an example of registering your app with PushWoosh in there.

Thanks! I replaced the code with whats on that page with the project ID from pushwoosh. When i run the program now it does not exit. But I do not get any messages or anything when i tried passing a message. Sorry but I’m still trying to learn about the notifications. i know how to use the events from buttons and other actions. Does the NotificationListener register the device token when i run the app? Or do i need to do something else myself?

Warren

Are you getting any messages in your console log?  Are you looking at the response returned by PushWoosh to see if it has any information?

check out:

http://docs.coronalabs.com/guide/events/appNotification/index.html

We have an example of registering your app with PushWoosh in there.

Thanks! I replaced the code with whats on that page with the project ID from pushwoosh. When i run the program now it does not exit. But I do not get any messages or anything when i tried passing a message. Sorry but I’m still trying to learn about the notifications. i know how to use the events from buttons and other actions. Does the NotificationListener register the device token when i run the app? Or do i need to do something else myself?

Warren

Are you getting any messages in your console log?  Are you looking at the response returned by PushWoosh to see if it has any information?