๐Ÿ“ฑ Progressive Web Apps (PWA) & Offline Strategy in Oracle APEX

๐Ÿ“ฑ Progressive Web Apps (PWA) & Offline Strategy in Oracle APEX

๐Ÿ”น About

Oracle APEX makes it incredibly easy to convert applications into Progressive Web Apps (PWA). But the real challenge begins when users expect the application to continue working even without internet connectivity.

In this blog, weโ€™ll explore how to build a true offline-capable Oracle APEX application using:

โœ” Progressive Web Apps (PWA)
โœ” Service Workers
โœ” Browser Local Storage
โœ” Offline Data Synchronization
โœ” Custom Offline Page Design

This approach is especially useful for:

  • Field workers
  • Sales teams
  • Survey applications
  • Warehouse management systems
  • Remote inspection apps

๐Ÿ› ๏ธ Tools and Technologies

  • Oracle APEX
  • JavaScript
  • Browser Local Storage
  • Service Workers
  • Oracle Database
  • PWA Manifest

๐Ÿš€ What is a Progressive Web App (PWA)?

A Progressive Web App is a web application that behaves like a native mobile app.

With PWA, users can:

โœ… Install the app on mobile/desktop
โœ… Access the app fullscreen
โœ… Use caching for faster performance
โœ… Work offline (partially/full)

Oracle APEX provides built-in support for enabling PWA functionality.


๐Ÿ”ฅ The Real Challenge: Offline Capability

Enabling PWA is easy.

The difficult part is:

๐Ÿ‘‰ What happens when internet connectivity drops?

Normally:

โŒ Form submissions fail
โŒ Data gets lost
โŒ Users cannot continue work

For field workers, this becomes a major business problem.


๐ŸŽฏ Goal of This Strategy

We want users to:

โœ” Continue entering data offline
โœ” Save data locally in browser storage
โœ” Automatically sync to Oracle DB when internet returns


๐Ÿ“Œ Step 1: Enable PWA in Oracle APEX

Go to:

Shared Components โ†’ Progressive Web App

Enable:

  • โœ” Installable
  • โœ” Offline Support
  • โœ” Service Worker

๐Ÿ“Œ Step 2: Configure PWA Manifest

The Manifest file controls how the application behaves as an installed app.

Example:

{
  "name": "Field Worker App",
  "short_name": "FieldApp",
  "start_url": "/ords/r/app",
  "display": "standalone",
  "background_color": "#ffffff",
  "theme_color": "#1976D2",
  "icons": [
    {
      "src": "icon-192.png",
      "sizes": "192x192",
      "type": "image/png"
    }
  ]
}

๐Ÿ“Œ Step 3: Configure Service Worker

The Service Worker acts like a proxy between browser and server.

It enables:

โœ… Offline caching
โœ… Faster loading
โœ… Background sync

Example:

self.addEventListener('install', event => {
    event.waitUntil(
        caches.open('apex-cache').then(cache => {
            return cache.addAll([
                '/',
                '/offline.html'
            ]);
        })
    );
});

๐Ÿ“Œ Step 4: Detect Online / Offline Status

Use JavaScript to detect internet connectivity.

window.addEventListener('offline', function() {
   console.log('Internet Disconnected');
});

window.addEventListener('online', function() {
   console.log('Internet Restored');
});

๐Ÿ“Œ Step 5: Save Data in Browser Local Storage

When internet is unavailable, save data locally instead of losing it.


Example: Save Offline Data

function saveOfflineData(empname, salary) {

   let offlineData =
      JSON.parse(localStorage.getItem("emp_data")) || [];

   offlineData.push({
      empname: empname,
      salary: salary,
      sync_status: 'PENDING'
   });

   localStorage.setItem(
      "emp_data",
      JSON.stringify(offlineData)
   );

   console.log("Saved Offline");
}

๐Ÿ“Œ Step 6: Synchronize Data When Internet Returns

Once connectivity returns:

โœ” Read local storage
โœ” Push data to Oracle DB
โœ” Clear synced records


Example Sync Logic

async function syncOfflineData() {

   let offlineData =
      JSON.parse(localStorage.getItem("emp_data")) || [];

   for (let row of offlineData) {

      await apex.server.process(
         "SAVE_EMP_DATA",
         {
            x01: row.empname,
            x02: row.salary
         }
      );

   }

   localStorage.removeItem("emp_data");

   console.log("Sync Completed");
}

๐Ÿ“Œ Step 7: Trigger Automatic Sync

window.addEventListener('online', function() {
   syncOfflineData();
});

๐Ÿ“Œ Step 8: Create AJAX Callback Process

BEGIN

   INSERT INTO emp_offline_data
   (
      emp_name,
      salary
   )
   VALUES
   (
      apex_application.g_x01,
      apex_application.g_x02
   );

END;

๐ŸŽจ The Offline Page Explained

Oracle APEX also allows you to customize the Offline Page shown when users lose connectivity.

Before modifying the Offline Page, review the Oracle APEX documentation related to:

Progressive Web App (PWA) Messages Requiring Translation

You will find several message names starting with:

APEX.PWA.*

These messages control:

  • Offline page title
  • Offline page body
  • PWA error messages
  • Unsupported device messages

๐Ÿ“Œ Important Offline Messages

๐Ÿ”น Offline Page Title

APEX.PWA.OFFLINE.TITLE

๐Ÿ”น Offline Page Body

APEX.PWA.OFFLINE.BODY

This is the most important message because it controls the actual HTML displayed on the Offline Page.


๐Ÿ’ก Why Use SVG?

It is recommended to use SVG graphics instead of PNG/JPG images because:

โœ… Lightweight
โœ… Browser renders directly
โœ… No server dependency
โœ… Works perfectly offline

Unlike PNG/JPG files, SVG does not require an additional server request.


๐Ÿš€ Steps to Customize Offline Page

Step 1

Go to:

Shared Components

Step 2

Under:

Globalization โ†’ Text Messages

Step 3

Click:

Create Text Message

Step 4

Enter Message Name:

APEX.PWA.OFFLINE.BODY

Step 5

Select the appropriate language.

Repeat for all supported languages.


Step 6

Enter your custom HTML / SVG / Text.

Example:

<div style="text-align:center;padding:40px;">

  <svg width="120" height="120" viewBox="0 0 24 24">
      <path fill="#1976D2"
            d="M12 2L1 21h22L12 2z"/>
  </svg>

  <h2>You Are Offline</h2>

  <p>
     Internet connection is currently unavailable.
     Your data will sync automatically once connection returns.
  </p>

</div>

๐Ÿ”ฅ Architecture Flow

User Enters Data
        โ†“
Internet Available?
        โ†“
   YES โ†’ Save to Oracle DB
        โ†“
   NO  โ†’ Save to Local Storage
        โ†“
Internet Restored
        โ†“
Sync Local Data to Oracle DB

๐ŸŽฏ Advantages of Offline Strategy

โœ… No data loss
โœ… Better field usability
โœ… Faster response time
โœ… Improved user experience
โœ… Works in low-network areas


โš ๏ธ Challenges in Offline APEX Apps

๐Ÿ”น Conflict Resolution

What if the same record changes online and offline?

๐Ÿ”น Data Security

Avoid storing sensitive data in local storage.

๐Ÿ”น Browser Storage Limits

Local Storage has size limitations.

๐Ÿ”น Sync Failures

Need retry logic for failed synchronization.


๐Ÿš€ Advanced Enhancements

You can further improve the solution with:

โœ” IndexedDB instead of Local Storage
โœ” Background Sync API
โœ” Offline Queue Management
โœ” Sync Status Dashboard
โœ” Push Notifications


๐Ÿ“Š Real-World Use Cases

This strategy is ideal for:

  • Logistics apps
  • Delivery tracking
  • Field inspections
  • Survey collection systems
  • Healthcare mobility solutions

๐ŸŽ‰ Conclusion

Oracle APEX makes Progressive Web Apps easy, but building a true offline-first application requires additional planning and strategy.

By combining:

โœ… PWA
โœ… Service Workers
โœ… Browser Local Storage
โœ… Offline Synchronization
โœ… Custom Offline Pages

you can create enterprise-grade applications that continue working even when the internet disappears.

This becomes a game changer for field workers and remote operations.

Comments

No comments yet. Why don’t you start the discussion?

    Leave a Reply

    Your email address will not be published. Required fields are marked *