ToothlessGear / node-gcm

A NodeJS wrapper library port to send data to Android devices via Google Cloud Messaging
https://github.com/ToothlessGear/node-gcm
Other
1.31k stars 206 forks source link

Use `to` for single registration ids/device keys/etc #134

Closed hypesystem closed 9 years ago

hypesystem commented 9 years ago

According to the new and fancy GCM specs, the field to may hold a single registration id or a single notification key. This should be used when only a single registration id is sent.

ashconnell commented 9 years ago

Does this plugin support topics via the to field?

hypesystem commented 9 years ago

We do not, currently, use the to field at all.

Can you give me some more detail on how you would normally support topics via the to field? I couldn't immediately find anything when I looked at the specs I linked above.

ashconnell commented 9 years ago

The to field is used for multiple purposes in the new spec

Topic Messaging: https://developers.google.com/cloud-messaging/topic-messaging Group Messaging: https://developers.google.com/cloud-messaging/notifications

You can pass in a topic: /topic/foo, a groupId (which is an alias for multiple devices), or just the deviceId

hypesystem commented 9 years ago

With 0.11 (not released yet) this will be possible by sending a message like so:

sender.send(message, "/topic/foo", function(error, result) {
    if(error) return console.error("Error", error);
    //...
});

That is exactly what this issue tracks: when it is closed, the feature will be in the master branch :)

Basically, if the second argument passed to send is a string it will go in the to field :)

hypesystem commented 9 years ago

These are great details and should probably be documented somewhere... I will look into that :)

hypesystem commented 9 years ago

@Deminetix version 0.11 has now been released. Let me know if all that group and topic messaging works --- I haven't tried that part of it yet, myself.