Push notification - two pushes instead of one

15 views
Skip to first unread message

Brian Burton

unread,
Feb 8, 2016, 1:04:18 PM2/8/16
to Coronium IO
Chris,
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 userId = in_data.to
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
answer2 = coronium.push.to( device, coronium.IOS, message, badge)
elseif os == "android" then
answer2 = coronium.push.to( device, coronium.ANDROID, message, badge)
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)






Chris Byerley

unread,
Feb 8, 2016, 4:47:25 PM2/8/16
to Brian Burton, Coronium IO
Thanks Brian. I'll take a look.

Cheers.

--
Learn more about the free Coronium Cloud at http://coronium.io
Free real-time Lua based game server at http://coronium.gs
Twitter: @coroniumio @coroniumgs @develephant
Site: http://develephant.net
---
You received this message because you are subscribed to the Google Groups "Coronium IO" group.
To unsubscribe from this group and stop receiving emails from it, send an email to coroniumio+...@googlegroups.com.
Visit this group at https://groups.google.com/group/coroniumio.
To view this discussion on the web visit https://groups.google.com/d/msgid/coroniumio/58f61351-940d-4ea9-a112-e4a62467e911%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Brian Burton

unread,
Feb 8, 2016, 11:37:07 PM2/8/16
to Coronium IO
Double push problem solved! It was a glitch in the app.
Thanks for a great tool Chris!
Reply all
Reply to author
Forward
0 new messages