Skip to content
Snippets Groups Projects
Unverified Commit 2784fe76 authored by Jaap Jan's avatar Jaap Jan Committed by GitHub
Browse files

Merge pull request #4 from goalgorilla/feature/3032708

#3032708 make sure the title reflects the name from the PWA settings page
parents 292d6a61 66fbf371
No related branches found
No related tags found
No related merge requests found
......@@ -11,8 +11,8 @@ self.addEventListener('push', function (event) {
return;
}
var sendNotification = function(payload, icon, url) {
var title = "Open Social";
var sendNotification = function(payload, icon, url, site_name) {
var title = site_name || "Open Social";
icon = icon || '/sites/default/files/images/touch/open-social.png';
payload = payload || 'You\'ve received a message!';
return self.registration.showNotification(title, {
......@@ -39,11 +39,11 @@ self.addEventListener('push', function (event) {
}
// The page is still open but unfocused, so focus the tab.
else if (clientList.length > 0) {
return sendNotification(data.message, data.icon, data.url);
return sendNotification(data.message, data.icon, data.url, data.site_name);
}
// The page is closed, send a push to retain engagement.
else {
return sendNotification(data.message, data.icon, data.url);
return sendNotification(data.message, data.icon, data.url, data.site_name);
}
})
);
......
......@@ -52,14 +52,17 @@ function activity_send_push_activity_insert(ActivityInterface $activity) {
return;
}
$pwa_settings = \Drupal::config('social_pwa.settings');
// Set fields for payload.
$message_to_send = html_entity_decode($message_to_send);
$fields = [
'message' => strip_tags($message_to_send),
'url' => $activity->getRelatedEntityUrl()->toString(),
'site_name' => $pwa_settings->get('name'),
];
$icon = \Drupal::config('social_pwa.settings')->get('icons.icon');
$icon = $pwa_settings->get('icons.icon');
if (!empty($icon)) {
// Get the file id and path.
$fid = $icon[0];
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment