notifme / notifme-sdk

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

Sending a multi-channel notification is not working! #19

Closed HarshaHegde1994 closed 6 years ago

HarshaHegde1994 commented 6 years ago

Hi, I was trying to send a mult-ichannel notification. 1st channel is sending the notification, however, rest of the channels are not sending any notifications.

BDav24 commented 6 years ago

Can you show me the code of your providers and notification?

HarshaHegde1994 commented 6 years ago

code for the provider

const notifme = new NotifmeSdk({
            channels: {
                push: config.push,
                sms: {
                    "providers":[{
                        "type": config.sms.providers.type,
                        "id": config.sms.providers.id,
                        send: async (request) => {
                            return await sendSMS(request,config)
                        }

                    }]
                }
            },
            useNotificationCatcher: config.isNotificationCatcher // <= this sends all your notifications to the catcher running on port 1025
        });

code for notification

notifmeSdk.send({push: {registrationToken: notificationObj.registrationToken,
                title: notificationObj.notificationMessage.title,
                body: notificationObj.notificationMessage.body,
                icon: notificationObj.notificationMessage.icon
            }},
            {sms: {
                to: notificationObj.smsTo,
                text: notificationObj.smsBody,
            }}
            )

Not sure where i went wrong.

BDav24 commented 6 years ago

send takes only one parameter containing all the channels:

notifmeSdk.send({
  push: {
    registrationToken: notificationObj.registrationToken,
    title: notificationObj.notificationMessage.title,
    body: notificationObj.notificationMessage.body,
    icon: notificationObj.notificationMessage.icon
  },
  sms: {
    to: notificationObj.smsTo,
    text: notificationObj.smsBody,
  }
)
HarshaHegde1994 commented 6 years ago

But the documentation says like this.

notifmeSdk.send({
  email: {
    from: 'me@example.com',
    to: 'john@example.com',
    subject: 'Hi John',
    html: '<b>Hello John! How are you?</b>'
  },
  sms: {
    from: '+15000000000',
    to: '+15000000001',
    text: 'Hello John! How are you?'
  },
  push: {
    registrationToken: 'xxxxx',
    title: 'Hi John',
    body: 'Hello John! How are you?',
    icon: 'https://notifme.github.io/notifme-sdk/img/icon.png'
  },
  webpush: {
    subscription: {
      keys: {
        auth: 'xxxxx',
        p256dh: 'xxxxx'
      },
      endpoint: 'xxxxx'
    },
    title: 'Hi John',
    body: 'Hello John! How are you?',
    icon: 'https://notifme.github.io/notifme-sdk/img/icon.png'
  }
})

I'm confused when you say 'one parameter containing all the channels'. How does that differ?

BDav24 commented 6 years ago
// Your code:
notifmeSdk.send({push: ...}, {sms: ...})

// What you should have:
notifmeSdk.send({push: ..., sms: ...})
HarshaHegde1994 commented 6 years ago

Oh!! sorry. Thanks for the reply....