Android PushWoosh Notifications problem

Ok, So I am having difficulty setting up push notifications using PushWoosh, I’ve spent hours trying to figure this out, read tons of documentation, did several searches on the forum and on google,I can’t seem to figure it out…If anyone can help me it’d be greatly appreciated.

This is my config.lua I have my actual project number where its supposed to be

application = { content = { width = 320, height = 480, scale = "letterbox", }, notification = { google = { -- This Project Number (also known as a Sender ID) tells Corona to register this application -- for push notifications with the Google Cloud Messaging service on startup. -- This number can be obtained from the Google API Console at: https://code.google.com/apis/console projectNumber = "xxxxxxxxx", }, }, }  

 Heres my build.settings

settings = { iphone = { plist= { UIApplicationExitsOnSuspend = false, UIPrerenderedIcon = true, UIStatusBarHidden = false, CFBundleIconFile = "Icon.png", CFBundleIconFiles = { "Icon.png", "Icon@2x.png", "Icon-60.png", "Icon-60@2x.png", "Icon-72.png", "Icon-72@2x.png", "Icon-76.png", "Icon-76@2x.png", "Icon-Small.png", "Icon-Small@2x.png", "Icon-Small-40.png", "Icon-Small-40@2x.png", "Icon-Small-50.png", "Icon-Small-50@2x.png", }, }, }, android = { permissions = { { name = ".permission.C2D\_MESSAGE", protectionLevel = "signature" }, }, usesPermissions = { -- Required by the MapView to fetch its contents from the Google Maps servers. "android.permission.INTERNET", "android.permission.GET\_ACCOUNTS", "android.permission.RECEIVE\_BOOT\_COMPLETED", "com.google.android.c2dm.permission.RECEIVE", ".permission.C2D\_MESSAGE", -- Optional permission used to display current location via the GPS. "android.permission.ACCESS\_FINE\_LOCATION", -- Optional permission used to display current location via WiFi or cellular service. "android.permission.ACCESS\_COARSE\_LOCATION", }, usesFeatures = { -- If you set permissions "ACCESS\_FINE\_LOCATION" and "ACCESS\_COARSE\_LOCATION" above, -- then you may want to set up your app to not require location services as follows. -- Otherwise, devices that do not have location sevices (such as a GPS) will be unable -- to purchase this app in the app store. { name = "android.hardware.location", required = false }, { name = "android.hardware.location.gps", required = false }, { name = "android.hardware.location.network", required = false }, }, }, orientation = { default = "portrait", supported = { "portait", "portraitUpsideDown", }, }, }

and my main.lua

local launchArgs = ... local json = require "json" if launchArgs and launchArgs.notification then native.showAlert( "launchArgs", json.encode( launchArgs.notification ), { "OK" } ) end local function registerWithPushWoosh (token) -- Register device with PushWoosh. PushWoosh account and setup required. local DeviceID = token local PW\_APPLICATION = "xxxxxxxx" --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", { "OK" } ) else --Registration worked 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"] = 3 -- 1 – iphone, 2 – blackberry, 3 – android, 4 – nokia, 5 – WP7, 7 – mac } } 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 local function onNotification( event ) if event.type == "remoteRegistration" then registerWithPushWoosh(event.token) end end Runtime:addEventListener( "notification", onNotification )

I tried several different codes for the main.lua, I went with the example pushwoosh provided and I went with the example in the corona documentation, None of which worked. When I did my searches, I found the above code, with that code, It registered my device with pushwoosh, because now I have 1 Subscriber, but I don’t receive any of the notifications I send to the device.

If any of you can help It would be greatly appreciated.

Thanks

Hi,

Try to check push notification status in “Pushes” tab. This way you can see if any error has happened during push notification delivery. Since you got 1 subscriber - client side should work correctly. I suppose this could be an issue with the Server Key configuration in the control panel.

I’m having the same frustration/ issue. In the push status is says “unauthorized”

I see i have 1 registered device. but i am not receiving the notifications.

Only happens on Android devices?

Did you check the http response provided by the server after you tried to register the device?

If you receive “Unauthorized” please make sure your Google Project ID (projectNumber = “xxxxxxxxx”,) and Server key are correct.

You also might want to try Browser key instead if the Server key is failing.

Thanks for all the help and assistance, it was actually a combination of things that resulted in it not working lol

first off, the code listed above works fine for me, I just wasn’t patient enough, so I kept changing the code thinking it wasn’t working.

But after I changed the code back to the one listed above and waited a bit, I received the notification. 

That’s great news!

Hi,

Try to check push notification status in “Pushes” tab. This way you can see if any error has happened during push notification delivery. Since you got 1 subscriber - client side should work correctly. I suppose this could be an issue with the Server Key configuration in the control panel.

I’m having the same frustration/ issue. In the push status is says “unauthorized”

I see i have 1 registered device. but i am not receiving the notifications.

Only happens on Android devices?

Did you check the http response provided by the server after you tried to register the device?

If you receive “Unauthorized” please make sure your Google Project ID (projectNumber = “xxxxxxxxx”,) and Server key are correct.

You also might want to try Browser key instead if the Server key is failing.

Thanks for all the help and assistance, it was actually a combination of things that resulted in it not working lol

first off, the code listed above works fine for me, I just wasn’t patient enough, so I kept changing the code thinking it wasn’t working.

But after I changed the code back to the one listed above and waited a bit, I received the notification. 

That’s great news!

i have the same problem and i don’t find any solution… help me please

We are finding that both Push and Local Notifications are not working on any of our Android Devices, but are working on iOS. when a notification is detected by the device, the following message appears in adb logcat (using the Local Notifications Sample Project):

E/NotificationService(  815): Not posting notification with icon==0: Notification(pri=0 icon=0 contentView=PACKAGE_NAME/0x1090086 vibrate=null sound=content://PACKAGE_NAME.files/assets/alarm.caf defaults=0x0 flags=0x18 when=1409134819245 ledARGB=0x0 contentIntent=Y deleteIntent=Y contentTitle=LocalNotificationsNew contentText=Wake up! tickerText=Wake up! kind=[null])

E/NotificationService(  815): WARNING: In a future release this will crash the app: PACKAGE_NAME

When using push notifications an alert sound will play but the actual notification will not.

We have found that this issue does not appear in an identical build we did on the 21st of August 2014, but it has appeared on every build done since 26th August 2014, these were done with the same versions and Corona and our IDE.

My investigation so far has indicated that the icon id must contain a valid value, of which 0 is not.

I have made a bug report for this issue, so with any luck we’ll have a solution soon.

UPDATE: The Corona staff fixed my issue that evening, I now have working notifications :slight_smile:

Hi Andy, 

i try to re-test now, and i have always my problem. 
with pushwoosh i can send a notification with additional data, i create a rich html page in their website, and push woos send my notification with the rich page, and when i receive my notification and i click in “OK”, my device go on the home page of my app and no on the rich html page. 

i show you the screen of the config in pushwoosh, i think that the problem is on my lua, but i don’t understand how i can change it… 

248878Capturedcran20140901111621.png

my main.lua : 

local launchArgs = ... local json = require "json" if launchArgs and launchArgs.notification then native.showAlert( "Bordeaux Privilèges", launchArgs.notification.alert, { "Ok" } ) end local function registerWithPushWoosh (token) -- Register device with PushWoosh. PushWoosh account and setup required. local DeviceID = token local PW\_APPLICATION = "5FD15-EA06D" --use your app id in pushwoosh local PW\_URL = "https://cp.pushwoosh.com/json/1.3/registerDevice" local deviceType = 1 -- default to iOS if ( system.getInfo("platformName") == "Android" ) then deviceType = 3 end local function networkListener( event ) if ( event.isError ) then --error occurred notify user native.showAlert( "Notification Registration Failed", "An Error Contacting the Server has Occurred", { "OK" } ) else --Registration worked 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"] = deviceType -- 1 – iphone, 2 – blackberry, 3 – android, 4 – nokia, 5 – WP7, 7 – mac } } 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 local function onNotification( event ) if event.type == "remoteRegistration" then registerWithPushWoosh(event.token) else native.showAlert( "Bordeaux Privilèges", event.alert, { "Ok" } ) end end local bg = display.newImage("bg.png", display.contentCenterX, display.contentCenterY) Runtime:addEventListener( "notification", onNotification ) 

if you have a idea… 

Kévin

i have the same problem and i don’t find any solution… help me please

We are finding that both Push and Local Notifications are not working on any of our Android Devices, but are working on iOS. when a notification is detected by the device, the following message appears in adb logcat (using the Local Notifications Sample Project):

E/NotificationService(  815): Not posting notification with icon==0: Notification(pri=0 icon=0 contentView=PACKAGE_NAME/0x1090086 vibrate=null sound=content://PACKAGE_NAME.files/assets/alarm.caf defaults=0x0 flags=0x18 when=1409134819245 ledARGB=0x0 contentIntent=Y deleteIntent=Y contentTitle=LocalNotificationsNew contentText=Wake up! tickerText=Wake up! kind=[null])

E/NotificationService(  815): WARNING: In a future release this will crash the app: PACKAGE_NAME

When using push notifications an alert sound will play but the actual notification will not.

We have found that this issue does not appear in an identical build we did on the 21st of August 2014, but it has appeared on every build done since 26th August 2014, these were done with the same versions and Corona and our IDE.

My investigation so far has indicated that the icon id must contain a valid value, of which 0 is not.

I have made a bug report for this issue, so with any luck we’ll have a solution soon.

UPDATE: The Corona staff fixed my issue that evening, I now have working notifications :slight_smile:

Hi Andy, 

i try to re-test now, and i have always my problem. 
with pushwoosh i can send a notification with additional data, i create a rich html page in their website, and push woos send my notification with the rich page, and when i receive my notification and i click in “OK”, my device go on the home page of my app and no on the rich html page. 

i show you the screen of the config in pushwoosh, i think that the problem is on my lua, but i don’t understand how i can change it… 

248878Capturedcran20140901111621.png

my main.lua : 

local launchArgs = ... local json = require "json" if launchArgs and launchArgs.notification then native.showAlert( "Bordeaux Privilèges", launchArgs.notification.alert, { "Ok" } ) end local function registerWithPushWoosh (token) -- Register device with PushWoosh. PushWoosh account and setup required. local DeviceID = token local PW\_APPLICATION = "5FD15-EA06D" --use your app id in pushwoosh local PW\_URL = "https://cp.pushwoosh.com/json/1.3/registerDevice" local deviceType = 1 -- default to iOS if ( system.getInfo("platformName") == "Android" ) then deviceType = 3 end local function networkListener( event ) if ( event.isError ) then --error occurred notify user native.showAlert( "Notification Registration Failed", "An Error Contacting the Server has Occurred", { "OK" } ) else --Registration worked 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"] = deviceType -- 1 – iphone, 2 – blackberry, 3 – android, 4 – nokia, 5 – WP7, 7 – mac } } 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 local function onNotification( event ) if event.type == "remoteRegistration" then registerWithPushWoosh(event.token) else native.showAlert( "Bordeaux Privilèges", event.alert, { "Ok" } ) end end local bg = display.newImage("bg.png", display.contentCenterX, display.contentCenterY) Runtime:addEventListener( "notification", onNotification ) 

if you have a idea… 

Kévin