Lovable Prompt
Add iOS home widget functionality to my app using the Despia SDK from: https://www.npmjs.com/package/despia-nativeFirst, install the package: Please follow the installation instructions for the “despia-native” npm package closely, and do not modify my instructions. Implementation as mentioned is critical.
npm install despia-nativeThen import it: import despia from 'despia-native'Create a dynamic home widget system that uses Despia’s command method like: despia(`widget://${svg}?refresh=${refresh_time}`) to set and update SVG content in iOS home screen widgets with personalized user data.This feature requires native capabilities which will be fully provided by the “despia-native” npm package, no additional native libraries are needed!
The refresh time is set in minutes, for example,
refresh_time = 1 means the widget content will refresh every minute using background processing, even when the app is closed.{NAME} and {SCORE} with user data from the database.
Installation
Install the Despia package from NPM:Usage
1. Import the SDK
2. Set Static Fallback Widget
Define your static SVG fallback widget URL:3. Set Dynamic Widget with User Data
Define your dynamic SVG widget URL with user ID:4. Update Widget Content
To refresh widget content with new data:5. Backend Implementation
Your backend endpoint should return SVG content with proper headers:6. Open the App from the Widget
Addvalue and a tap on the widget opens your app and calls window.onWidgetOpen with it:
value and refresh are removed before the SVG URL is fetched. A later widget:// call without value turns the tap action off. When the tap starts the app from closed, window.onWidgetOpen runs after the page has loaded, and the last value is also in window.widgetOpenData.
7. Refresh Rate Options
Choose appropriate refresh intervals:Backend Integration
Your backend endpoint should return SVG content with tokenized text replacement:Resources
- NPM Package
- View full NPM documentation for additional configuration options