Hello,
I have been trying trying and trying to get push notification work on device through pushwoosh. I followed all steps and triple checked everything but not able to get push notification on device. I can see through console that my device is successfully registered with pushwoosh and which I can also see at pushwoosh dashboard. But I can not get push notification to receive on device. I also followed all the Apple related work but still no luck. Can anybody tell me if someone had a better luck or where I can be wrong.
Here is my code for pushwoosh
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" or event.type == "local" ) then --handle the push or local notification native.showAlert( "Push Notification", "Push notification recieved.", { "OK" } ) 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 = "app-id" --use your app ID in PushWoosh local PW\_URL = "https://cp.pushwoosh.com/json/1.1/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 )
Any help please!