Skip to content

Commit e05e550

Browse files
committed
Merge branch 'main' into prep-1.0.1
2 parents ac7221a + 7f7caea commit e05e550

File tree

9 files changed

+213
-5
lines changed

9 files changed

+213
-5
lines changed

README.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,33 @@ To run this extension from the repo (and not from a pre-built package) on a loca
3131
php bin/phpbbcli.php extension:enable phpbb/webpushnotifications # install the extension
3232
```
3333

34+
## Browser Support
35+
36+
| Web Browser | Platform | Web Push Notification Support | Background Notification Support (When Browser Closed) |
37+
|---------------------|---------------|-------------------------------|-------------------------------------------------------|
38+
| **Google Chrome** | macOS | ✅ Yes | ❌ No (unless running in the background) |
39+
| | Windows | ✅ Yes | ❌ No (unless running in the background) |
40+
| | iOS | ❌ No | ❌ No |
41+
| | Android | ✅ Yes | ✅ Yes |
42+
| **Safari** | macOS | ✅ Yes | ✅ Yes |
43+
| | iOS | ✅ Yes | ✅ Yes (site must be added to Home Screen first) |
44+
| **Microsoft Edge** | macOS | ✅ Yes | ❌ No (unless running in the background) |
45+
| | Windows | ✅ Yes | ❌ No (unless running in the background) |
46+
| | iOS | ❌ No | ❌ No |
47+
| | Android | ✅ Yes | ✅ Yes |
48+
| **Mozilla Firefox** | macOS | ✅ Yes | ❌ No |
49+
| | Windows | ✅ Yes | ❌ No |
50+
| | iOS | ❌ No | ❌ No |
51+
| | Android | ✅ Yes | ❌ No |
52+
| **Opera** | macOS | ✅ Yes | ❌ No |
53+
| | Windows | ✅ Yes | ❌ No |
54+
| | iOS | ❌ No | ❌ No |
55+
| | Android | ✅ Yes | ❌ No |
56+
57+
*(unless running in the background)* means the browsers have background processes running (they’re not fully quit).
58+
59+
More info here https://caniuse.com/push-api
60+
3461
## Testing Push Notifications
3562

3663
Testing push notifications necessitates user-to-user interactions to observe the notification behavior accurately. Follow the steps outlined below to effectively test push notifications (the browser recommendations are what we have seen work in local environments):

event/listener.php

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ public static function getSubscribedEvents()
8686
'core.acp_main_notice' => 'compatibility_notice',
8787
'core.acp_board_config_edit_add' => 'acp_pwa_options',
8888
'core.validate_config_variable' => 'validate_pwa_options',
89+
'core.help_manager_add_block_after' => 'wpn_faq',
8990
];
9091
}
9192

@@ -279,6 +280,44 @@ public function validate_pwa_options($event)
279280
}
280281
}
281282

283+
/**
284+
* Add Web Push info to the phpBB FAQ
285+
*
286+
* @param \phpbb\event\data $event The event object
287+
* @return void
288+
*/
289+
public function wpn_faq($event)
290+
{
291+
if ($event['block_name'] === 'HELP_FAQ_BLOCK_BOOKMARKS')
292+
{
293+
$this->language->add_lang('webpushnotifications_faq', 'phpbb/webpushnotifications');
294+
295+
$this->template->assign_block_vars('faq_block', [
296+
'BLOCK_TITLE' => $this->language->lang('HELP_FAQ_WPN'),
297+
'SWITCH_COLUMN' => false,
298+
]);
299+
300+
$questions = [
301+
'HELP_FAQ_WPN_WHAT_QUESTION' => 'HELP_FAQ_WPN_WHAT_ANSWER',
302+
'HELP_FAQ_WPN_HOW_QUESTION' => 'HELP_FAQ_WPN_HOW_ANSWER',
303+
'HELP_FAQ_WPN_SESSION_QUESTION' => 'HELP_FAQ_WPN_SESSION_ANSWER',
304+
'HELP_FAQ_WPN_SUBBING_QUESTION' => 'HELP_FAQ_WPN_SUBBING_ANSWER',
305+
'HELP_FAQ_WPN_GENERAL_QUESTION' => 'HELP_FAQ_WPN_GENERAL_ANSWER',
306+
];
307+
308+
$faq_rows = [];
309+
foreach ($questions as $question => $answer)
310+
{
311+
$faq_rows[] = [
312+
'FAQ_QUESTION' => $this->language->lang($question),
313+
'FAQ_ANSWER' => $this->language->lang($answer),
314+
];
315+
}
316+
317+
$this->template->assign_block_vars_array('faq_block.faq_row', $faq_rows);
318+
}
319+
}
320+
282321
/**
283322
* Add errors to the error array
284323
*

language/en/info_acp_webpushnotifications.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@
3939

4040
$lang = array_merge($lang, [
4141
'ACP_WEBPUSH_EXT_SETTINGS' => 'Web Push settings',
42-
'ACP_WEBPUSH_REMOVE_WARNING' => 'Web Push Notifications are now built-in to phpBB',
43-
'ACP_WEBPUSH_REMOVE_NOTICE' => 'The extension “phpBB Browser Push Notifications” is no longer needed and should be uninstalled and removed.<br>All settings and user preferences associated with the extension will be migrated into phpBBs built-in push notifications when you uninstall the extension.',
42+
'ACP_WEBPUSH_REMOVE_WARNING' => 'Web Push Notifications are now built into phpBB',
43+
'ACP_WEBPUSH_REMOVE_NOTICE' => 'The extension “phpBB Browser Push Notifications” is no longer needed and should be uninstalled and removed.<br>All settings and user preferences associated with the extension will be migrated into phpBBs built-in push notifications when you uninstall the extension.',
4444
'LOG_CONFIG_WEBPUSH' => '<strong>Altered Web Push settings</strong>',
4545
'LOG_WEBPUSH_MESSAGE_FAIL' => '<strong>Web Push message could not be sent:</strong> %s',
4646
'LOG_WEBPUSH_SUBSCRIPTION_REMOVED' => '<strong>Removed Web Push subscription:</strong>» %s',

language/en/install.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
//
3939

4040
$lang = array_merge($lang, [
41-
'PHPBB_VERSION_MAX_ERROR' => 'This extension can not be installed on this board. This is a phpBB 4 board, which already contains the features in this extension.',
41+
'PHPBB_VERSION_MAX_ERROR' => 'This extension cannot be installed on this board. This is a phpBB 4 board, which already contains the features in this extension.',
4242
'PHPBB_VERSION_MIN_ERROR' => 'phpBB ' . \phpbb\webpushnotifications\ext::PHPBB_MIN_VERSION . ' or newer is required.',
4343
'PHP_VERSION_ERROR' => 'PHP ' . \phpbb\webpushnotifications\ext::PHP_MIN_VERSION . ' or newer is required.',
4444
'PHP_EXT_MISSING' => 'The “%s” extension for PHP must be installed on this server.',

language/en/webpushnotifications_common_acp.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,5 +49,5 @@
4949
'PWA_ICON_SIZE_INVALID' => '“%s” does not have the correct image dimensions.',
5050
'PWA_ICON_MIME_INVALID' => '“%s” must be a PNG image file.',
5151
'PWA_IMAGE_INVALID' => '“%s” does not appear to be a valid image file.',
52-
'PWA_IMAGE_NOT_PROVIDED' => '%s field must not be empty. All icon fields must contain and image.',
52+
'PWA_IMAGE_NOT_PROVIDED' => '%s field must not be empty. All icon fields must contain an image.',
5353
]);
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<?php
2+
/**
3+
*
4+
* phpBB Browser Push Notifications. An extension for the phpBB Forum Software package.
5+
*
6+
* @copyright (c) 2024, phpBB Limited <https://www.phpbb.com>
7+
* @license GNU General Public License, version 2 (GPL-2.0)
8+
*
9+
*/
10+
11+
/**
12+
* DO NOT CHANGE
13+
*/
14+
if (!defined('IN_PHPBB'))
15+
{
16+
exit;
17+
}
18+
19+
if (empty($lang) || !is_array($lang))
20+
{
21+
$lang = [];
22+
}
23+
24+
// DEVELOPERS PLEASE NOTE
25+
//
26+
// All language files should use UTF-8 as their encoding and the files must not contain a BOM.
27+
//
28+
// Placeholders can now contain order information, e.g. instead of
29+
// 'Page %s of %s' you can (and should) write 'Page %1$s of %2$s', this allows
30+
// translators to re-order the output of data while ensuring it remains correct
31+
//
32+
// You do not need this where single placeholders are used, e.g. 'Message %d' is fine
33+
// equally where a string contains only two placeholders which are used to wrap text
34+
// in a url you again do not need to specify an order e.g., 'Click %sHERE%s' is fine
35+
//
36+
// Some characters you may want to copy&paste:
37+
// ’ » “ ” …
38+
//
39+
40+
$lang = array_merge($lang, [
41+
'HELP_FAQ_WPN' => 'Web Push Notifications for Browsers',
42+
'HELP_FAQ_WPN_WHAT_QUESTION' => 'What are web push notifications?',
43+
'HELP_FAQ_WPN_WHAT_ANSWER' => 'Web push notifications enhance phpBB’s notification system by allowing real-time notifications to be sent directly to your desktop or mobile device, even if you’re not actively browsing the forum. These notifications function like app alerts, providing instant updates for private messages, post interactions, moderation actions, and more.',
44+
'HELP_FAQ_WPN_HOW_QUESTION' => 'How can I receive forum notification alerts on my computer or mobile device?',
45+
'HELP_FAQ_WPN_HOW_ANSWER' => 'Navigate to “Notification options” in your UCP (User Control Panel) and click “Enable web push notifications.” Your browser may ask for permission to send notifications—be sure to allow it. If you’re still not receiving notifications, check your device’s system settings to ensure notifications are enabled for your browser. For mobile devices such as iPhone or iPad, you may need to add the forum site to your Home Screen for push notifications to work, effectively turning it into a standalone web app. Follow your mobile device’s instructions to enable push notifications for <a href="https://www.xda-developers.com/how-enable-safari-notifications-iphone/" target="_blank">iPhone/iPad</a> or <a href="https://support.google.com/chrome/answer/3220216?hl=en&co=GENIE.Platform%3DAndroid&oco=0" target="_blank">Android</a>.',
46+
'HELP_FAQ_WPN_SESSION_QUESTION' => 'Will I receive notifications if I am logged out?',
47+
'HELP_FAQ_WPN_SESSION_ANSWER' => 'Yes, you will continue to receive notifications even if you’re logged out.',
48+
'HELP_FAQ_WPN_SUBBING_QUESTION' => 'Why are the “Enable Push Notifications” buttons disabled?',
49+
'HELP_FAQ_WPN_SUBBING_ANSWER' => 'If the “Enable Push Notifications” buttons is visible but cannot be clicked, your browser or device likely doesn’t support push notifications. Try using a different browser or device that supports this feature.',
50+
'HELP_FAQ_WPN_GENERAL_QUESTION' => 'What if I’m still having trouble receiving notifications?',
51+
'HELP_FAQ_WPN_GENERAL_ANSWER' => 'Make sure this forum is allowed to send notifications in your browser settings. Also, verify that your device’s system settings permit notifications from your web browser or app. Some browsers deliver notifications even when closed, whilst others only do so when the browser is open. <a href="https://caniuse.com/push-api" target="_blank">View this table for browser support information.</a> Finally, if you’re using an ad blocker, review its settings to make sure it’s not configured to block push notifications.',
52+
]);

language/en/webpushnotifications_module_acp.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
$lang = array_merge($lang, [
4141
'ACP_WEBPUSH_SETTINGS_EXPLAIN' => 'Here you can enable Web Push for board notifications. Web Push is a protocol for the real-time delivery of events to user agents, commonly referred to as push messages. It is compatible with the majority of modern browsers on both desktop and mobile devices. Users can opt to receive Web Push alerts in their browser by subscribing and enabling their preferred notifications in the UCP.<br><br>To enable push notifications on Apple mobile devices, your site needs to function as a Progressive Web Application (PWA). This requires users to add your site to their device’s home screen. For an improved user experience, you can find additional PWA settings under <strong>Board settings</strong>, where you can configure an optional app name and app icons for how your site will appear on users’ home screens.',
4242
'WEBPUSH_ENABLE' => 'Enable Web Push',
43-
'WEBPUSH_ENABLE_EXPLAIN' => 'Allow users to receive notifications in their browser or device via Web Push. To utilize Web Push, you must input or generate valid VAPID identification keys.',
43+
'WEBPUSH_ENABLE_EXPLAIN' => 'Allow users to receive notifications in their browser or device via Web Push. To utilise Web Push, you must input or generate valid VAPID identification keys.',
4444
'WEBPUSH_GENERATE_VAPID_KEYS' => 'Generate Identification keys',
4545
'WEBPUSH_VAPID_PUBLIC' => 'Server identification public key',
4646
'WEBPUSH_VAPID_PUBLIC_EXPLAIN' => 'The Voluntary Application Server Identification (VAPID) public key is shared to authenticate push messages from your site.<br><em><strong>Caution:</strong> Modifying the VAPID public key will automatically render all Web Push subscriptions invalid.</em>',
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<?php
2+
/**
3+
*
4+
* phpBB Browser Push Notifications. An extension for the phpBB Forum Software package.
5+
*
6+
* @copyright (c) 2024, phpBB Limited <https://www.phpbb.com>
7+
* @license GNU General Public License, version 2 (GPL-2.0)
8+
*
9+
*/
10+
11+
/**
12+
* DO NOT CHANGE
13+
*/
14+
if (!defined('IN_PHPBB'))
15+
{
16+
exit;
17+
}
18+
19+
if (empty($lang) || !is_array($lang))
20+
{
21+
$lang = [];
22+
}
23+
24+
// DEVELOPERS PLEASE NOTE
25+
//
26+
// All language files should use UTF-8 as their encoding and the files must not contain a BOM.
27+
//
28+
// Placeholders can now contain order information, e.g. instead of
29+
// 'Page %s of %s' you can (and should) write 'Page %1$s of %2$s', this allows
30+
// translators to re-order the output of data while ensuring it remains correct
31+
//
32+
// You do not need this where single placeholders are used, e.g. 'Message %d' is fine
33+
// equally where a string contains only two placeholders which are used to wrap text
34+
// in a url you again do not need to specify an order e.g., 'Click %sHERE%s' is fine
35+
//
36+
// Some characters you may want to copy&paste:
37+
// ’ » “ ” …
38+
//
39+
40+
$lang = array_merge($lang, [
41+
'HELP_FAQ_WPN' => 'Браузерные уведомления',
42+
'HELP_FAQ_WPN_WHAT_QUESTION' => 'Что такое браузерные уведомления?',
43+
'HELP_FAQ_WPN_WHAT_ANSWER' => 'Браузерные уведомления отправляются непосредственно на настольное или мобильное устройство получателя, даже если он не находится на данной конференции. Такие уведомления работают как и уведомления от приложений, обеспечивая немедленное информирование о личных сообщениях, событиях в форумах, модераторских активностях и так далее.',
44+
'HELP_FAQ_WPN_HOW_QUESTION' => 'Как получать браузерные уведомления на компьютер или мобильное устройство?',
45+
'HELP_FAQ_WPN_HOW_ANSWER' => 'Откройте Личный раздел и на закладке «Личный настройки» перейдите в блок «Изменить настройки уведомлений». Щёлкните кнопку «Включить» рядом с заголовком «Браузерные push—уведомления». При этом может поступить запрос от браузера на разрешение получения уведомлений от данного сайта. Для получения уведомлений необходимо принять данный запрос. Если после этих настроек браузерные уведомления не работают, убедитесь, что системные настройки устройства разрешают выбранному браузеру отправлять уведомления. Для таких мобильных устройств, как iPhone или iPad, может потребоваться добавить сайт конференции на «Домашний экран» для того, чтобы получать браузерные уведомления. При этом сайт конференции будет работать как самостоятельное приложение. Обратитесь к инструкции по использованию соответствующего мобильного устройства, чтобы включить уведомления для <a href="https://www.xda-developers.com/how-enable-safari-notifications-iphone/" target="_blank">iPhone/iPad</a> или <a href="https://support.google.com/chrome/answer/3220216?hl=en&co=GENIE.Platform%3DAndroid&oco=0" target="_blank">Android</a>.',
46+
'HELP_FAQ_WPN_SESSION_QUESTION' => 'Будут ли приходить браузерные уведомления, если пользователь вышел из своей учётной записи на конференции?',
47+
'HELP_FAQ_WPN_SESSION_ANSWER' => 'Да, браузерные уведомления продолжат поступать, даже если пользователь вышел из своей учётной записи на конференции.',
48+
'HELP_FAQ_WPN_SUBBING_QUESTION' => 'Почему кнопка «Включить» рядом с заголовком «Браузерные push—уведомления» неактивна?',
49+
'HELP_FAQ_WPN_SUBBING_ANSWER' => 'Если кнопка «Включить» рядом с заголовком «Браузерные push—уведомления» неактивна, возможно, выбранный браузер или мобильное устройство не поддерживают браузерные уведомления. Попробуйте использовать другой браузер или устройство, поддерживающие данную функцию.',
50+
'HELP_FAQ_WPN_GENERAL_QUESTION' => 'Браузерные уведомления включены и настроены, но всё равно не поступают. Что делать?',
51+
'HELP_FAQ_WPN_GENERAL_ANSWER' => 'Убедитесь, что сайту конференции разрешено отправлять уведомления в настройках выбранного браузера, а также что в системных настройках самого устройства отправка уведомлений разрешена для данного браузера или приложения сайта. В некоторых браузерах уведомления действуют, только если браузер открыт или работает в фоновом режиме. Для получения более подробной инфомации <a href="https://caniuse.com/push-api" target="_blank">обратитесь к таблице.</a> Если используется блокировщик рекламы, проверьте его настройки и убедитесь, что он не блокирует браузерные уведомления.',
52+
]);

0 commit comments

Comments
 (0)