1. Go to this page and download the library: Download raneomik/nette-pwa library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
raneomik / nette-pwa example snippets
use Raneomik\NettePWA\Push\Notification;
$failures = $pushSender->send("player/{$id}", new Notification('Bob joined', 'Time to play!', url: $link));
$pushSender->send(['room/abc', 'room/def'], $notification); // each browser once
final class TopicAccess implements Raneomik\NettePWA\Push\TopicAuthorizer
{
public function __construct(private Nette\Security\User $user) {}
public function isAllowed(string $topic): bool
{
return str_starts_with($topic, 'room/') || $topic === "player/{$this->user->getId()}";
}
}
$manifest = $manifestProvider->manifest;
$manifest->themeColor; // ?string
$manifest->display; // Display::Standalone
$manifest->icons[0]->src; // 'img:icon', as configured (the JSON gets the asset URL)
$manifest->extra['categories']; // the extra members stay raw