Lovable Prompt
Add native rewarded ad functionality to my app using the Despia SDK from: https://www.npmjs.com/package/despia-nativeFirst, install the package: Important: Only grant the reward to the user when the status parameter equals the string Important Security Considerations:Always verify the user agent includes “despia” to prevent unauthorized function calls from web browsers:Daily Limits - Abuse Prevention:We strongly recommend implementing daily limits to prevent abuse. Track the number of ads watched per user per day and enforce a reasonable maximum (e.g., 5-10 ads per day). For high-value rewards, consider implementing backend validation to verify ad completions.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 rewarded ad system that displays video advertisements and grants rewards to users who complete watching them. Use despia("displayrewardedad://") to trigger the ad display.Add a button that allows users to watch ads to earn rewards:e.g. “Watch Ad for 100 Coins”, “Get Free Lives”The Despia Native Runtime will call the global function
updateRewardedStatus(status) when a rewarded ad interaction occurs. You need to define this callback function in your code.'true'. This means the ad was successfully watched to completion. If the status is anything other than 'true', do not grant any reward - the user either skipped the ad or it failed to complete.The function will receive the following data:This feature requires native capabilities which will be fully provided by the “despia-native” npm package, no additional native libraries are needed!