I don’t know the specifics of how Corona communicates with Apple/Google, but this is how it works on the code side.
This code sets up the runtime event that receives notifications from the OS.
Runtime:addEventListener( "notification", OnNotification )
This is the listener function that processes any notifications.
local function onNotification(event) if event.type == "remoteRegistration" then -- This device has just been registered for push notifications. -- Store the Registration ID that was assigned to this application by Google or Apple. myRegistrationId = event.token -- Display a message indicating that registration was successful. local message = "This app has successfully registered for push notifications." native.showAlert("Information", message, { "OK" }) -- Print the registration event to the log. print("### --- Registration Event ---") -- -- Here is where you put code to register with your push notification service -- else -- A push notification has just been received. Print it to the log. print("### --- Notification Event ---") -- here is where you respond to a push notification that comes in while the -- app is running. end end
Now when your application is started, Corona tells Apple or Google this app uses push. Then Apple/Google return a token and the token is passed to your app via the OnNotification listener. You will then get the “remoteRegistration” event. As per the code above, you then save that token.
The Corona code is more or less identical for Apple and Google. Google requires a little more work on the setup though. But once set up, your Corona code can handle either pretty seamlessly. As for sending pushes, I have not looked into how Google expects them to be delivered to them. I am sure it’s much different than how Apple does it. However once setup (server-side code), delivering it from Corona to your server script again will be pretty much the same.
I originally had my own server and was able to send Apple pushes fine. In the end I just decided to use a 3rd party service as it handles the load, the automatic removal of expired tokens, setting up the connection and as mentioned prior, sending multiple pushes.
If you need server code examples for Google push, perhaps someone else will chime in with how in that department.