I came across the mod_parse module a while ago when I was implementing push notifications into an app. I really like the module and I decided to use the analytical parts in my app but unfortunately, the module doesn’t have push yet so I started hacking away and found it was easier and faster than I could ever imagined.

To save everyone the hassle of writing your own code I decided to share mine with the Corona community. Just add it to your main.lua, sign up with parse and get your appID and REST key and your good to go.

After you got your parse keys, build for device and launch the app, go to your parse and see the data browser for your device. I have only run this code on iOS.

Grab the code here and get your push notifications with parse going too!

local appID = "Your appID"
local RESTapiKey = "Your REST ApiKey"
local function notificationListener(event)
 
      if (event.type == "local") then
 
      local badgeNum = native.getProperty( "applicationIconBadgeNumber" )
            badgeNum = badgeNum - 1
            native.setProperty( "applicationIconBadgeNumber", badgeNum )
 
      elseif (event.type == "remote") then
 
           if (event.badge and event.badge > 0) then
              native.setProperty("applicationIconBadgeNumber", event.badge - 1)
           end
 
      elseif (event.type == "remoteRegistration") then
 
           local platform = "ios"
 
           if (system.getInfo("platformName") == "Android") then
                 platform = "android"
           end
 
       local function networkListener(event)
            if (event.isError) then
                print(" ===>>> PARSE LISTENER ERROR RESPONSE : ", event.response)
            else
                print(" ===>>> PARSE LISTENER RESPONSE: ", event.response)
            end
        end
 
        local headers = {
              ["X-Parse-Application-Id"] = appID,
              ["X-Parse-REST-API-Key"] = RESTapiKey,
              ["Content-Type"] = "application/json"
             }
 
        local bodyData = {
            -- These two fields must be added at parse.com first.
              ["deviceName"]  = tostring( system.getInfo("name") ),
              ["deviceModel"] = tostring( system.getInfo("architectureInfo") ),
 
              ["deviceType"]  = platform,
              ["deviceToken"] = event.token,
              ["badge"] = native.getProperty("applicationIconBadgeNumber"),
              ["timeZone"] = -3600,
              ["channels"] = {"MyPushChannel"}
             }
 
       local body = json.encode(bodyData)
 
       local params = {
             headers = headers,
             body = body
        }
        network.request( "https://api.parse.com/1/installations" ,"POST", networkListener, params)
 
     end
 
end
 
Runtime:addEventListener("notification", notificationListener )