Facebook 

SMFHacks.com - Celebrating 20 Years!

+-

SMFHacks.com

+- User Information

Welcome, Guest.
Please login or register.
 
 
 
Forgot your password?

+- Forum Stats

Members
Total Members: 4341
Latest: jmac32here
New This Month: 2
New This Week: 0
New Today: 0
Stats
Total Posts: 44306
Total Topics: 7676
Most Online Today: 293
Most Online Ever: 27044
(May 30, 2026, 09:10:16 pm)
Users Online
Members: 1
Guests: 205
Total: 206

Author Topic: [Mod]ProgressiveWebApp - for Mobile Phones SMF 2.1  (Read 24059 times)

0 Members and 1 Guest are viewing this topic.

[Mod]ProgressiveWebApp - for Mobile Phones SMF 2.1
« on: »
ProgressiveWebApp - for Mobile Phones SMF 2.1




https://www.smfhacks.com/index.php?action=downloads;sa=view;down=257

Mobile-First PWA Shell for SMF 2.1
  Version 1.0.0
================================================================================

  Author:      vbgamer45 / SMF Hacks
  Website:      https://www.smfhacks.com
  Compatibility: SMF 2.1.x (tested on 2.1.6)
  License:      MIT
  Package ID:  smfmods:pwa-shell

================================================================================
  OVERVIEW
================================================================================

  Transforms your SMF forum into a modern Progressive Web App on mobile devices.
  Installs as a standard SMF package using only hooks - zero core file edits.
  The desktop experience is completely untouched.

  Mobile users get:
  - Bottom tab navigation (Feed, Boards, Alerts, Messages, Profile)
  - Sticky header with search and dark mode toggle
  - Pull-to-refresh gesture
  - Swipe-right from left edge to go back
  - Floating action button for new post/reply
  - "Add to Home Screen" install prompt (iOS and Android)
  - Dark mode with system preference detection
  - Push notifications for forum alerts
  - Offline fallback page when network is unavailable
  - Service worker caching for faster page loads

================================================================================
  REQUIREMENTS
================================================================================

  - SMF 2.1.x
  - PHP 7.4+ (PHP 8.x recommended)
  - OpenSSL PHP extension (required for push notification VAPID keys)
  - cURL PHP extension (required for sending push notifications)
  - HTTPS (required by browsers for service workers and push notifications)

================================================================================
  INSTALLATION
================================================================================

  1. Download the package zip file.
  2. Go to Admin > Packages > Install a New Package.
  3. Upload the zip file and click Install.
  4. You will be redirected to the PWA Settings page after install.
  5. Configure your preferences (see Settings section below).

  On install, the mod will:
  - Generate VAPID encryption keys for push notifications (via OpenSSL)
  - Create a database table for push subscriptions
  - Register a scheduled task for push notification delivery
  - Register three integration hooks (no core files modified)

================================================================================
  UNINSTALLATION
================================================================================

  1. Go to Admin > Packages > Installed Packages.
  2. Find "Mobile-First PWA Shell" and click Uninstall.

  This will cleanly remove:
  - All mod files (PHP sources, CSS, JS, icons, templates)
  - The push subscriptions database table
  - All mod settings (including VAPID keys)
  - The scheduled task
  - All registered hooks

================================================================================
  ADMIN SETTINGS
================================================================================

  Found at: Admin > Configuration > PWA Shell Settings

  General Settings:
  - Enable PWA Shell          Master on/off toggle for the mobile experience.
  - Enable Push Notifications Allow users to receive push notifications.

  Appearance:
  - Default Dark Mode        Light / Dark / Follow System.
                              Users can override with the toggle in the header.
  - Accent Color              Primary theme color used in the manifest, browser
                              toolbar, and UI accents. Default: #557EA0

  Behavior:
  - Install Prompt Delay      Number of page visits before showing the
                              "Add to Home Screen" banner. Default: 2
  - Offline Message          Text shown on the offline fallback page when the
                              user has no network connection.

  Push Notifications:
  - VAPID Contact Email      Email address used as the VAPID subject. Push
                              services (Google, Apple) may contact this address.
  - VAPID Public Key          Auto-generated on install. Display-only.
                              Do not change unless you want to invalidate all
                              existing push subscriptions.

================================================================================
  FEATURES IN DETAIL
================================================================================

  BOTTOM TAB NAVIGATION
  ---------------------
  A fixed bottom navigation bar with 5 tabs, injected via JavaScript so it
  works with any SMF theme. Tabs:

    Feed      (?action=unread)            Recent unread topics
    Boards    (board index)                Board listing
    Alerts    (?action=profile;area=showalerts)  Your alerts
    Messages  (?action=pm)                Personal messages
    Profile    (?action=profile)            Your profile (or Login for guests)

  The active tab is highlighted based on the current page URL. Badge counts
  for unread alerts and PMs are shown on the Alerts and Messages tabs.

  STICKY HEADER
  -------------
  A compact header replaces SMF's default top section on mobile with:
  - Forum name / page title
  - Search button
  - Dark mode toggle (moon/sun icon)

  FLOATING ACTION BUTTON
  ----------------------
  A "+" button in the bottom-right corner. Context-aware behavior:
  - Viewing a topic: scrolls to and focuses the quick reply box
  - Viewing a board: opens "New Topic" for that board
  - Elsewhere: navigates to unread topics
  Only shown for logged-in users.

  DARK MODE
  ---------
  Full dark theme using CSS custom properties. Three modes:
  - Light: always light
  - Dark: always dark
  - System: follows the device's prefers-color-scheme setting

  The admin sets the default. Users toggle with the header button.
  Preference is saved to localStorage (works for guests too).
  Overrides all standard SMF CSS classes: windowbg, titlebg, catbg,
  roundframe, buttons, inputs, links, code blocks, quotes, etc.

  PULL TO REFRESH
  ---------------
  Pull down from the top of the page to refresh. Shows a spinner indicator.
  Haptic feedback when the pull threshold is crossed (on supported devices).

  SWIPE GESTURES
  --------------
  Swipe right from the left edge of the screen to go back (history.back).
  Mimics the native iOS/Android back gesture.

  SERVICE WORKER & OFFLINE
  ------------------------
  A service worker is registered for all users (mobile and desktop) to
  enable caching and offline support.

  Caching strategies:
  - Static assets (CSS, JS, images, fonts): Stale-while-revalidate.
    Served instantly from cache, updated in the background.
  - HTML pages: Network-first with cache fallback.
    Always tries the network. Falls back to cached version if offline.
  - AJAX/API calls: Network-only. Never cached to prevent stale data.

  When offline with no cached page available, a styled offline fallback page
  is shown with a "Try Again" button. Respects dark mode preference.

  The service worker is served via ?action=pwa-sw with a
  Service-Worker-Allowed: / header, allowing root scope even though SMF
  URLs are query-string based. It is also installed to the webroot as
  sw.js for direct access.

  ADD TO HOME SCREEN
  ------------------
  Prompts users to install the forum as an app on their device.

  Android/Chrome:
    Intercepts the browser's beforeinstallprompt event and shows a custom
    banner with an "Install" button after the configured number of visits.

  iOS/Safari:
    iOS does not support beforeinstallprompt. The banner instead shows
    manual instructions: "Tap [share icon] then Add to Home Screen"
    with the actual iOS share icon displayed inline.

  The banner is not shown if:
  - The app is already installed (standalone mode detected)
  - The user dismissed the banner previously
  - The visit count hasn't reached the configured delay

  WEB APP MANIFEST
  ----------------
  Served dynamically at ?action=pwa-manifest with values populated from
  your forum settings:
  - name / short_name: from forum name
  - description: from meta description setting
  - theme_color: from accent color setting
  - icons: 192px, 512px, and maskable 512px from /pwa-icons/
  - display: standalone
  - orientation: portrait

================================================================================
  PUSH NOTIFICATIONS
================================================================================

  OVERVIEW
  --------
  When enabled, users can subscribe to receive push notifications on their
  devices. Notifications are delivered for forum alerts such as replies,
  mentions, quotes, and likes.

  HOW IT WORKS
  ------------
  1. The user visits the forum and is prompted to enable notifications.
    - On Android: shown after 3 page visits, or immediately in the
      installed PWA.
    - On iOS: only shown inside the installed home screen app (push
      does not work in regular Safari). Requires iOS 16.4+.
  2. If the user allows, a push subscription is created via the browser's
    Push API and sent to the server.
  3. A scheduled task ("PWA Push Notifications") runs every 2 minutes.
  4. It queries the user_alerts table for new unread alerts belonging to
    members who have push subscriptions.
  5. Each alert is converted into a human-readable notification and sent
    to all of that member's subscribed devices via the Web Push protocol.

  SUPPORTED ALERT TYPES
  ---------------------
  The following SMF events generate push notifications:

    Event                Push Notification Title
    -------------------  --------------------------------
    @mention            "Mentioned by {name}"
    Quote                "Quoted by {name}"
    Like                "{name} liked your post"
    Reply (watched)      "New reply from {name}"
    New topic (watched)  "New topic by {name}"
    Buddy request        "Buddy Request"
    Group approved      "Group Request Approved"
    Any other alert      "New Notification" (generic)

  Each notification includes the topic subject and a direct link to the
  relevant content. Tapping a notification opens the forum to that page.

  TECHNICAL DETAILS
  -----------------
  - Uses VAPID authentication (keys auto-generated on install via OpenSSL)
  - Payload encryption per RFC 8291 (Web Push Message Encryption)
  - ECDH key exchange + AES-128-GCM encryption
  - Pure PHP implementation using openssl extension - no Composer or
    external libraries required
  - Stale subscriptions (HTTP 410) are automatically cleaned up
  - Push delivery uses cURL
  - Alert tracking uses a high-water mark (last processed alert ID) to
    avoid duplicate notifications

  SCHEDULED TASK
  --------------
  Name:        PWA Push Notifications
  Location:    Admin > Scheduled Tasks
  Frequency:  Every 2 minutes (configurable in admin)
  Description: Checks for new alerts and sends push notifications to
              members with subscribed devices.


================================================================================
  BROWSER COMPATIBILITY
================================================================================

  Mobile (full PWA experience):
  - Chrome for Android 67+
  - Samsung Internet 9.2+
  - Safari iOS 16.4+ (push requires installed PWA)
  - Firefox for Android 100+
  - Edge for Android 67+

  Desktop (service worker caching only, no shell UI):
  - All modern browsers with service worker support

  Push notification support:
  - Chrome 50+, Edge 17+, Firefox 44+, Safari 16.4+ (installed PWA only)
  - NOT supported: Safari on macOS (as of 2025)

================================================================================
  CUSTOMIZING ICONS
================================================================================

  The default icons are placeholder images with a blue background and "F"
  letter. To replace them with your forum's branding:

  1. Create PNG images at these sizes:
    - 192x192 pixels (icon-192.png)
    - 512x512 pixels (icon-512.png)
    - 512x512 pixels with extra padding for safe zone (icon-maskable-512.png)

  2. Upload them to your forum's /pwa-icons/ directory, replacing the
    existing files.

  For the maskable icon, keep important content within the center 80% of
  the image. The outer 10% on each side may be cropped by the device.

  Tip: Use https://maskable.app to preview and test your maskable icon.

================================================================================
  TROUBLESHOOTING
================================================================================

  "VAPID key generation failed" on install:
    Your server's OpenSSL may not find its config file. The installer tries
    multiple fallback paths. Check that openssl.cnf exists and PHP's OpenSSL
    extension supports EC (P-256) keys. PHP 7.4+ with OpenSSL 1.1+ required.

  Service worker not registering:
    Ensure your forum is served over HTTPS. Service workers require a secure
    context. Check browser DevTools > Application > Service Workers for errors.

  Push notifications not arriving:
    - Check Admin > Scheduled Tasks: ensure "PWA Push Notifications" is
      enabled and running (last run time should be recent).
    - Verify the VAPID Contact Email is set in PWA Settings.
    - Check that the user has allowed notifications (browser permissions).
    - On iOS: push only works in the installed home screen app, not Safari.

  Bottom nav not showing:
    The mobile shell only activates on mobile viewports (max-width: 768px)
    and when the mod is enabled. Check Admin > PWA Shell Settings.

  Icons not displaying:
    Ensure the /pwa-icons/ directory exists in your forum root with the
    PNG files. Check file permissions (readable by web server).

  Dark mode not persisting:
    Dark mode preference is saved to localStorage. If the user clears
    browser data, the preference resets to the admin default.
« Last Edit: March 18, 2026, 02:31:13 pm by SMFHacks »
Get your Forum Ranked! at https://www.forumrankings.net - find out how your forum compares with others!

Like What I do? Support me at https://www.patreon.com/vbgamer45/

Re: [Mod]ProgressiveWebApp - for Mobile Phones SMF 2.1
« Reply #1 on: »
The download link doesn't work. I get a 404 file not found error.

Re: [Mod]ProgressiveWebApp - for Mobile Phones SMF 2.1
« Reply #2 on: »
The download link doesn't work. I get a 404 file not found error.
Try now!
Get your Forum Ranked! at https://www.forumrankings.net - find out how your forum compares with others!

Like What I do? Support me at https://www.patreon.com/vbgamer45/
Like Like x 1 View List

 

Related Topics

  Subject / Started by Replies Last post
2 Replies
16742 Views
Last post January 25, 2010, 09:45:23 pm
by Black Viper
1 Replies
11881 Views
Last post August 30, 2013, 08:46:57 am
by SMFHacks
2 Replies
8874 Views
Last post April 23, 2022, 09:51:55 am
by SMFHacks
1 Replies
13637 Views
Last post August 28, 2023, 03:12:57 pm
by SMFHacks
3 Replies
1768 Views
Last post August 10, 2026, 05:53:25 am
by SMFHacks

+- Recent Topics

Registration - anti bot pattern matching by SMFHacks
November 01, 2026, 07:20:17 pm

EZPortal 8 by davejo
October 21, 2026, 01:01:54 pm

Downloads Pro 7.0 Released by SMFHacks
October 07, 2026, 07:35:30 pm

[Mod]ActivityPub Federation for SMF 2.1 by SMFHacks
October 01, 2026, 05:03:45 pm

Newsletter Pro 4.0 Released by SMFHacks
September 23, 2026, 08:08:24 pm

Can't remove or restore any item from the recycle bin by SMFHacks
September 22, 2026, 11:01:51 am

MCP Server for SMF 2.1 - let Claude, ChatGPT or Cursor run your admin chores by SMFHacks
September 12, 2026, 02:50:45 pm

Suggestions for improvements to Ultimate Shoutbox & Chatroom by davejo
September 02, 2026, 01:35:09 am

Automatic Sorting of Categories by Kiwi
August 31, 2026, 12:36:09 am

' appears as ' in Most Viewed (and Recent Items ?) by SMFHacks
August 22, 2026, 11:01:56 pm

Powered by EzPortal