pushmeup icon indicating copy to clipboard operation
pushmeup copied to clipboard

send_notification (single notification!) is returning an array of responses

Open LucasLMartini opened this issue 11 years ago • 0 comments

This is really minor, but I cracked my head here for half an hour figuring this out:

In gcm/core.rb, you use send_notifications (plural) inside send_notification (singular).

Problem is, the plural form expects multiple responses, and, rightly so, it delivers an array of responses.

But in send_notification (singular), the user would be expecting a single response object, in this method there's no reason to return an array, because there will be a single response for a single notification.

Change send_notification like so below and problem SHOULD be solved (didn't test):

def self.send_notification(device_tokens, data = {}, options = {})
  n = GCM::Notification.new(device_tokens, data, options)
  self.send_notifications([n])[0]
end

This might also apply to APNS and Microsoft, but I've only delved in GCM so far!

Thanks for the great gem!

LucasLMartini avatar Jun 20 '13 23:06 LucasLMartini