First, I have push notification working (yea!) through PushBots using
coronium.push.to. I will post some example code later once I have had a chance to clean it up.
Second, I am getting two notices each time instead of one. Here is my (not very clean) code:
local in_data=coronium.input()
local message = "You have received a new message"
local badge = "+1"
local answer = coronium.user.getUser(userId)
local answer2
if answer.result.deviceToken and answer.result.os then -- make sure a device is registered
local device = answer.result.deviceToken
local os = answer.result.os
if os == "IOS" then
elseif os == "android" then
end
coronium.log("push sent")
else
coronium.log("No device token, push not sent")
end
Any ideas on why I would get two notifications? ( I am storing the os & token independent of the addDevice function).
Also, I could not get the answer.result.devices to work so that I could send to multiple registered devices. Any suggestions? Currently mod_user.lua (server) push will only send to devices[1] instead of all registered devices.
I noted that mongo was storing the first device as [0], but user.push is sending to devices[1]. I realize that lua starts counting tables at 1, but mongo is starting at 0, so this could be a problem (haven't checked into it any further)