notifme / notifme-sdk

A Node.js library to send all kinds of transactional notifications.
https://notifme.github.io/www/
MIT License
1.94k stars 150 forks source link

FCM device groups #69

Closed baskin closed 3 years ago

baskin commented 4 years ago

Hi Team, I wasn't able to figure out how to send an FCM notification to a device group. Any help would be greatly appreciated? FWIW, the underlying library used (https://github.com/ToothlessGear/node-gcm) supports sending to device groups.

Thanks,

BDav24 commented 4 years ago

Hi @baskin, the problem is that we use an intermediate lib node-pushnotifications which calls node-gcm only with registrationTokens param (see https://github.com/appfeel/node-pushnotifications/blob/master/src/sendGCM.js#L17) when node-gcm seems to expect notifications keys in the to param (https://github.com/ToothlessGear/node-gcm#recipients).

baskin commented 4 years ago

Thanks @BDav24 . I realized that and opened a ticket with `node-pushnotifications. I'll try and have it supported there first and open this back later.

baskin commented 4 years ago

Hi @BDav24 , the maintainers of node-pushnotifications are working on API changes to support device groups. Please see if you would like to opine on the API on the above ticket.

baskin commented 4 years ago

Hi @BDav24, the maintainers of node-pushnotifications have proposed some changes in their library in this ticket.

Would it possible for you to test it out -- such that it fits in with the usage in notifme-sdk?

BDav24 commented 4 years ago

From what I understand of the pull request (https://github.com/appfeel/node-pushnotifications/pull/131) and the future documentation (https://github.com/appfeel/node-pushnotifications/tree/dev/fcm-recipients#send-to-custom-recipients-device-groups-or-topics), you'll be able to do:

notifmeSdk.send({
  push: {
    registrationToken: 'xxxxx', // any string strictly longer than 64 (because of https://github.com/appfeel/node-pushnotifications/blob/master/src/push-notifications.js#L53)
    recipients: { to: 'topicName' },
    ...
  }
})

So no code to change (except node-pushnotifications version upgrade).

alex-friedl commented 4 years ago

@BDav24 @baskin I released the change with v.1.4.0.

baskin commented 4 years ago

So no code to change (except node-pushnotifications version upgrade).

Yes. Looks like.

Thanks @BDav24 and @alex-friedl

BDav24 commented 3 years ago

Available from https://github.com/notifme/notifme-sdk/releases/tag/v1.10.0