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.3k stars 208 forks source link

addParam/setParam Message methods #273

Closed telekosmos closed 7 years ago

telekosmos commented 7 years ago

Hi there We'd like to set timeToLive param in the Message object just depending on another param (conditionally). In the Usage section, how to configure the Message object on creation is described, but not how to configure the object later if the object is created without any param.

Digging in the code we've found methods addParam, setParam for Message class, but we are confused by the paramType.

May someone to provide some example on how to use it/them???

Cheers!!!

hypesystem commented 7 years ago

The short answer is that this isn't supported. Once the timeToLive has been set it is not meant to be changed.

I think your best solution might be deferring creation of the Message object until you know what the TTL should be.

All of this should be easier to deal with once v1 comes around. Unfortunately I don't know when that will be.

telekosmos commented 7 years ago

Thanks for the quick and concise reply. We are using a legacy version (actually 0.11.1 :-S) and, diving in the code, we found that in that versions the params of the object can be updated by using message.params property. We are trying just set the TTL by message.params.timeToLive=TTL and seems to be working.

Anyway, we will seriously consider delaying the object creation. Cheers again!!!

hypesystem commented 7 years ago

No problem and good luck :smile: