Hello, I’m trying to get push notifications working with easyapns but having trouble. For some reason it doesn’t seem to be connecting to the server. If I use the address directly in a browser everything works fine, hoping someone can spot an obvious mistake I’ve made! Here’s the code I’m using:
local launchArgs = ...
local json = require "json"
if launchArgs and launchArgs.notification then
native.showAlert( "launchArgs", json.encode( launchArgs.notification ), { "OK" } )
end
local function networkListener( event )
if ( event.isError ) then --error occurred notify user
native.showAlert( "Notification Registration Failed", "Error", { "OK" } )
else
native.showAlert( "RESPONSE: " .. event.response )
end
end
-- notification listener
local function onNotification( event )
if event.type == "remoteRegistration" then
local easyurl = "http://clients.zerofiftyone.co.uk/push/apns.php?task=register"
easyurl=easyurl.."&appname="..\_G.appname
easyurl=easyurl.."&appversion="..\_G.appversion
easyurl=easyurl.."&deviceuid="..system.getInfo("deviceID")
easyurl=easyurl.."&devicetoken="..event.token
easyurl=easyurl.."&devicename="..system.getInfo("name")
easyurl=easyurl.."&devicemodel="..system.getInfo("model")
easyurl=easyurl.."&deviceversion="..system.getInfo("platformVersion")
easyurl=easyurl.."&pushbadge=enable"
easyurl=easyurl.."&pushalert=enable"
easyurl=easyurl.."&pushsound=enable"
easyurl=string.gsub(easyurl," ","%%20")
network.request ( easyurl, "GET", networkListener )
elseif event.type == "remote" then
native.showAlert( "remote", json.encode( event ), { "OK" } )
end
end
Runtime:addEventListener( "notification", onNotification )
I’m getting the pop up on the phone that say’s error. also while I’m here, I’m unsure of the pushbadge, pushalert and pushsound settings and how you should set them properly, at the moment I’m just setting them all to enabled… [import]uid: 110859 topic_id: 30556 reply_id: 330556[/import]
Here’s the code if anyone else searches: