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