- 🇨🇦Canada Nathan Tsai
I'm thinking of working on this feature.
Some ideas:
- Alter the content type edit form
- Store the notification template in configuration to keep things simple for now.
- Only send out the notification if the node is published.
Any feedback?
- 🇨🇦Canada Nathan Tsai
I think this simplest custom approach would be:
function _mymodule_node_presave(\Drupal\node\NodeInterface $node) {
_mymodule_notify_new_users($node);
}function _mymodule_notify_new_users(\Drupal\node\NodeInterface $node) {
if ($node->getType() !== 'MY TYPE") {
return;
}// Only send if a new node + is published.
// TODO: enable sending if initially unpublished, then later published
if (!($node->isNew() && $node->isPublished())) {
return;
}$onesignal = \Drupal::service('onesignal');
$onesignal->addNotification([
"included_segments" => ["Subscribed Users"], // TODO: allow user to customer user
"headings" => ["en" => "English Header"],
"contents" => ["en" => "English Message"],// optional
"chrome_web_image" => "https://yoursite.com/4x3-with-min-width-1350-large-image",
"chrome_web_icon" => "https://yoursite.com/256x256-icon",
"chrome_web_badge" => "https://yoursite.com/72x72-badge",// optional
"data" => ["nid" => $node->id(),],
]);
} - 🇨🇦Canada Nathan Tsai
Okay, first attempt.
Not multilingual and will probably want to use a service later one. Would love to get some feedback first though :)
- last update
8 months ago Composer require failure - last update
8 months ago PHPLint Failed - last update
8 months ago PHPLint Failed - last update
8 months ago Composer require failure - Status changed to Needs review
8 months ago 8:47pm 16 March 2024 - 🇨🇦Canada Nathan Tsai
I don't know how to run tests on a MR - so here's the patch!
- last update
8 months ago Composer require failure - last update
8 months ago PHPLint Failed - Issue was unassigned.