I write an application that uses Parse.com for remote push notifications sending. With the last corona build I receive an event.token in remoteRegistration event and I try to send it as “installationId” to the Parse. This is my code:
[lua]local function registerToParseInstallation()
objectClass = “installations”
headers[“Content-Type”] = “application/json”
local channelsSent = {}
channelsSent[1] = “continued”
local message
if system.getInfo( “platformName” ) == “Android” then
message = {deviceType = “android” , channels = channelsSent, installationId = userDeviceToken }
elseif system.getInfo ( “platformName” ) == “iPhone OS” then
message = {deviceType = “ios” , channels = channelsSent, deviceToken = userDeviceToken }
end
params.body = json.encode( message )
log ("params.body = " … params.body)
network.request( baseUrl … objectClass, “POST”, networkListenerregisterToParseInstallation, params)
end
local function onNotification( event )
if event.type == “remoteRegistration” then
native.showAlert( “remoteRegistration”, event.token, { “OK” } )
print ("device token is received: "… event.token)
userDeviceToken = event.token
registerToParseInstallation()
end
end
Runtime:addEventListener( “notification”, onNotification )[/lua]
This code works fine for iOS devices, but for Android devices I receive Error from the Parse with code “132” that installationId is invalid.
I added android permissions that are written in this link:
https://parse.com/tutorials/android-push-notifications
but I don’t know how to implement the follow thing (this is copy-paste from the link):
============================
- Registering for the Push Service
To use push notifications, your application must register this background service. Add the following XML to your AndroidManifest.xml file immediately before the closing tag:
So how should I define and where if I am the service android and receiver android?
Or does I am missing something else here?
Thanks [import]uid: 172733 topic_id: 34323 reply_id: 334323[/import]