Sure,
Build Settings:
[lua]
plugins =
{
[“plugin.notifications”] =
{
publisherId = “com.coronalabs”
},
},
notification =
{
iphone =
{
types = { “badge”, “sound”, “alert” }
}
}
[/lua]
Top of main.lua
[lua]
local notifications = require( “plugin.notifications” )
notifications.registerForPushNotifications()
local launchArgs = …
if ( launchArgs and launchArgs.notification ) then
print( launchArgs.notification.type )
print( launchArgs.notification.name )
print( launchArgs.notification.sound )
print( launchArgs.notification.alert )
print( launchArgs.notification.badge )
print( launchArgs.notification.applicationState )
end
local json = require(“json”)
local deviceToken
local function notificationListener( event )
print( “notification engine started!” )
if ( event.type == “remote” and event.applicationState == “active” ) then
--handle the push or local notification
print( "type ", event.type )
print ("event alert ", event.alert )
elseif ( event.type == “remoteRegistration” ) then
local deviceToken = event.token
--local deviceType = 1 --default to iOS
print( “Event Token is” … " " … event.token )
end
end
– The notification Runtime listener should be handled from within “main.lua”
Runtime:addEventListener( “notification”, notificationListener )
[/lua]
I am planning on implementing my own push server, however i have stripped all the code from the remoteregister callback for now as the callback isn’t even being called.