function pwa_webpush_library in Progressive Web App 7.2
Implements hook_library().
File
- modules/
pwa_webpush/ pwa_webpush.module, line 97
Code
function pwa_webpush_library() {
$path = drupal_get_path('module', 'pwa_webpush');
$module_version = pwa_version_assets('pwa_webpush');
return [
// Main script with all the subscription logic
'webpush' => [
'version' => $module_version,
'js' => [
$path . '/js/register.js' => [
'scope' => 'footer',
],
],
'dependencies' => [
[
'pwa',
'register',
],
[
'pwa',
'sha256',
],
],
],
// Handle anonymous subscriptions differently for security and performance.
'anonymous' => [
'version' => $module_version,
'js' => [
$path . '/js/anonymous.js' => [
'scope' => 'footer',
],
],
'dependencies' => [
[
'pwa_webpush',
'webpush',
],
],
],
// Script for the UI to enable notifications.
'button' => [
'version' => $module_version,
'js' => [
$path . '/js/button.js' => [
'scope' => 'footer',
],
],
'dependencies' => [
[
'pwa_webpush',
'webpush',
],
],
],
// Forcibly register users when permission is already granted.
'autoregister' => [
'version' => $module_version,
'js' => [
$path . '/js/autoregister.js' => [
'scope' => 'footer',
],
],
'dependencies' => [
[
'pwa_webpush',
'webpush',
],
],
],
];
}