[Bug]: Adding target_channel to the Notification class
What happened?
It seems there is an issue with the @onesignal/[email protected] in which, if I create a notification class object:
const notification = new Notification();
notification.target_channel = 'email';
client.createNotification(notification);
The target_channel is undefined. I started to have this issue when I was integrating the email target channel.
HOWEVER, if I create the notification with:
client.createNotification({
...notification,
target_channel: 'email
});
It does work. I tried also with the alpha version and the problem is the same.
Steps to reproduce?
1. Install @onesignal/[email protected]
2. Add the following snippet:
const notification = new Notification();
...include subscription_ids or aliases
notification.target_channel = 'email';
client.createNotification(notification);
What did you expect to happen?
Expect to send emails and not push notifications
Relevant log output
Code of Conduct
- [x] I agree to follow this project's Code of Conduct
Just to add a bit more information about this issue, apparently the REST API reference contains more properties that are not included in the nodejs library, such as email_from_name, email_reply_to_address and email_sender_domain.
https://documentation.onesignal.com/reference/email#body-email-sender-domain
As I wanted to make sure that the problem wasn't in some configuration that I did in Onesignal, I tried to use the REST API instead. I've added all missing parameters and the request got an 200_OK. However, There was something strange happening. I tried to send an email using the email dashboard from onesignal and it worked. BUT, when I replicated the same and parameters as onesignal dashboard I got an 200_OK but didn't receive any email.
I wonder if there is any distinction between how the emails are sent on the dashboard and how they are sent through the REST api. For email specifics, I am using include_aliases instead of subscription_ids. Not sure if that is relevant for this or not.
Thanks for reporting this @ricardoribas, and for including all of these details. I'll update those missing properties to the library model from the REST API definition.
As for the difference between the dashboard and API behavior, I'll need to look more into that and get back to you. Just from your description, I would make sure you can fetch users by those included_aliases and confirm that they are subscribed by email.