Pushwoosh Android notification FAIL

Hi guys, I’m going mad about push notifications in my app. I followed every tutorial I’ve found (included the pushwoosh official) but nothing happens, at the first start no popup for push notification comes out. I created my app project in google dev, enabled google cloud posting and copied the server key into pushwoosh. Then first configured config.lua as follows:

--calculate the aspect ratio of the device: local aspectRatio = display.pixelHeight / display.pixelWidth application = { content = { width = aspectRatio \> 1.5 and 320 or math.ceil( 480 / aspectRatio ), height = aspectRatio \< 1.5 and 480 or math.ceil( 320 \* aspectRatio ), scale = "letterBox", fps = 30, graphicsCompatibility = 1, }, imageSuffix = { ["@2x"] = 1.5, ["@4x"] = 3.0, }, notification = { google = { projectNumber = "214414349737" }, } }

build.settings configuration

 android = { usesPermissions = { -- Required by the MapView to fetch its contents from the Google Maps servers. "android.permission.INTERNET", -- Optional permission used to display current location via the GPS. "android.permission.ACCESS\_FINE\_LOCATION", "android.permission.ACCESS\_NETWORK\_STATE", "android.permission.WRITE\_EXTERNAL\_STORAGE", "com.google.android.providers.gsf.permission.READ\_GSERVICES", "android.permission.ACCESS\_FINE\_LOCATION", -- Optional permission used to display current location via WiFi or cellular service. "android.permission.ACCESS\_COARSE\_LOCATION", --Chiamate "android.permission.READ\_PHONE\_STATE", --Chiamate2 "android.permission.CALL\_PHONE", --Fotocamera "android.permission.CAMERA", "android.permission.WRITE\_EXTERNAL\_STORAGE", --Notifiche PUSH "android.permission.GET\_ACCOUNTS", "android.permission.RECEIVE\_BOOT\_COMPLETED", "com.google.android.c2dm.permission.RECEIVE", ".permission.C2D\_MESSAGE", },

and then the main.lua

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 notificationListener( event ) if ( event.type == "remote" ) then --handle the push notification elseif ( event.type == "remoteRegistration" ) then --code to register your device with the service end end Runtime:addEventListener( "notification", notificationListener ) local function notificationListener( event ) if ( event.type == "remote" or event.type == "local" ) then --handle the push or local notification elseif ( event.type == "remoteRegistration" ) then local deviceToken = event.token local deviceType = 1 --default to iOS if ( system.getInfo("platformName") == "Android" ) then deviceType = 3 end print( "Setting up with PushWoosh" ) local DeviceID = event.token local PW\_APPLICATION = "93E79-7FD0E" --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 native.showAlert( "Notification Registration Failed", "An Error Contacting the Server has Occurred.", { "OK" } ) else --registration successful! print( "PushWoosh registration successful", system.getInfo("deviceID") ) end end local commands\_json = { ["request"] = { ["application"] = PW\_APPLICATION, ["device\_id"] = DeviceID, ["language"] = "en", --OR: system.getPreference( "ui", "language" ), ["hw\_id"] = system.getInfo("deviceID"), ["timezone"] = -3600, --offset in seconds ["device\_type"] = deviceType } } local post\_body = json.encode( commands\_json ) local headers = {} headers["Content-Type"] = "application/json" headers["Accept-Language"] = "en-US" local params = {} params.headers = headers params.body = post\_body network.request ( PW\_URL, "POST", networkListener, params ) end end Runtime:addEventListener( "notification", notificationListener )

I’m going REALLY mad, I don’t understand what’s wrong… Any help is really appreciated. Thanks in advance

Nobody can help me? Please, I really need this! There isn’t a step by step guide for nooks…

Nobody can help me? Please, I really need this! There isn’t a step by step guide for nooks…

Hi, have you been able to solve  this?

I see that in the code you posted you have  “local function notificationListener( event )”  two times and the first one doesn’t have the required instructions, but I don’t know if it’s a mistake you made when posting or if your code really is like that.

Anyway, the same thing is happening to me, logcat shows “pushwoosh registration succesful” but pushwoosh shows 0 users.

Yes, the notificationListener function (the correct one) needs to be declared BEFORE You addRuntim…

Also, check to be clear whether your app is communicating with the Production push service, or the development sandbox push service…

Hi, have you been able to solve  this?

I see that in the code you posted you have  “local function notificationListener( event )”  two times and the first one doesn’t have the required instructions, but I don’t know if it’s a mistake you made when posting or if your code really is like that.

Anyway, the same thing is happening to me, logcat shows “pushwoosh registration succesful” but pushwoosh shows 0 users.

Yes, the notificationListener function (the correct one) needs to be declared BEFORE You addRuntim…

Also, check to be clear whether your app is communicating with the Production push service, or the development sandbox push service…