Local Push

Schedule Client Side Local Push Notifications

The Despia Local Push SDK enables your application to send notifications to users without requiring an internet connection. This powerful feature allows you to deliver time-sensitive alerts, reminders, and messages to users even when they are offline.

Quick Start

1. Configure a Basic Notification

Send a simple notification using the Local Push SDK:

window.despia = `sendlocalpushmsg://push.send?s=60=msg!Hello&!#New Message&!#https://myapp.com`

2. Customize Notification Parameters

Create a more customized notification with specific timing, title, message, and URL:

const seconds = 5
const title = "Quick Reminder"
const message = "Don't forget to save!"
const url = "https://myapp.com/save"

window.despia = `sendlocalpushmsg://push.send?s=${seconds}=msg!${message}&!#${title}&!#${url}`

How It Works

Offline Capability

The Local Push SDK leverages the device's native notification system to deliver messages without requiring an active internet connection.

Notification Parameters

The SDK accepts several parameters to customize your notifications:

  • Time delay (in seconds)

  • Message content

  • Notification title

  • URL to open when clicked

User Experience

When triggered, notifications appear in the device's notification center just like standard push notifications, providing a seamless user experience.

Implementation Examples

Here's how you can implement the Local Push SDK in your applications:

// Basic implementation example
window.despia = `sendlocalpushmsg://push.send?s=60=msg!Hello&!#New Message&!#https://myapp.com`

// EXAMPLES FOR NO-CODE/LOW-CODE TOOLS
            
// ---------- WEWEB ----------     
// WEWEB example using wwWorkflow to handle local push notifications
// 1. Create a Native WeWeb Global Workflow and return the variable:         
const seconds = 5
const title = "Quick Reminder"
const message = "Don't forget to save!"
const url = "https://myapp.com/save"

window.despia = `sendlocalpushmsg://push.send?s=${seconds}=msg!${message}&!#${title}&!#${url}`;

// ---------- WIZED ---------- 
// WIZED example using Wized's JS API
const seconds = 5
const title = "Quick Reminder"
const message = "Don't forget to save!"
const url = "https://myapp.com/save"

window.despia = `sendlocalpushmsg://push.send?s=${seconds}=msg!${message}&!#${title}&!#${url}`;

// OPTIONAL - Track notification in your system
const result = await Wized.requests.execute('TRACK_NOTIFICATION');
console.log(result);
            
// ---------- NORDCRAFT / TODDLE ---------- 
// For Nordcraft / Toddle - trigger an event with the notification data
// Create a custom event handler in your project settings
const seconds = 5
const title = "Quick Reminder"
const message = "Don't forget to save!"
const url = "https://myapp.com/save"

window.despia = `sendlocalpushmsg://push.send?s=${seconds}=msg!${message}&!#${title}&!#${url}`;

Data Structure

The Local Push SDK uses a specific URL-like string format to configure notifications:

// Format
window.despia = `sendlocalpushmsg://push.send?s=[SECONDS]=msg![MESSAGE]&!#[TITLE]&!#[URL]`

// Parameters explained:
// [SECONDS] - Time in seconds before showing the notification
// [MESSAGE] - The notification message content
// [TITLE] - The notification title
// [URL] - The URL to open when notification is clicked

Best Practices

Timing

  • Use appropriate timing for notifications based on user context

  • Avoid setting extremely short delays (< 3 seconds) as they may not register properly

  • Consider user time zones for scheduled notifications

Content

  • Keep notification messages concise and actionable

  • Use clear titles that indicate the notification purpose

  • Ensure URLs are valid and lead to relevant content

  • Test notifications thoroughly across different devices

Complete Implementation Example

Here's a more comprehensive example of implementing the Local Push SDK:

// Function to send a local push notification
function sendLocalNotification(delaySeconds, message, title, targetUrl) {
    // Validate inputs
    if (!delaySeconds || !message || !title) {
        console.error("Missing required notification parameters");
        return false;
    }

    // Set default URL if none provided
    const url = targetUrl || window.location.href;
    
    // Format and send the notification
    try {
        window.despia = `sendlocalpushmsg://push.send?s=${delaySeconds}=msg!${message}&!#${title}&!#${url}`;
        console.log("Local notification scheduled");
        return true;
    } catch (error) {
        console.error("Failed to schedule notification:", error);
        return false;
    }
}

// Example usage
const notificationSent = sendLocalNotification(
    30,
    "Your order #12345 has been processed successfully!",
    "Order Update",
    "https://myapp.com/orders/12345"
);

if (notificationSent) {
    // Additional logic after notification is scheduled
    updateNotificationLog({
        type: "order_update",
        timestamp: new Date().getTime(),
        orderId: "12345"
    });
}

Troubleshooting

Common Issues

Notification Not Showing

  • Ensure the syntax for the window.despia string is correct

  • Check that the delay time is appropriate (not too short or too long)

  • Verify that notifications are enabled in the device settings

  • Test with a simple notification to rule out parameter issues

Notification Shows But URL Doesn't Open

  • Ensure the URL is properly formatted and encoded if it contains special characters

  • Verify the URL is accessible from the device

  • Check if the application has the necessary permissions to open external URLs

Need Help?

For additional support or questions, please contact our support team at support@despia.com

Updated on