react-native-pubscale-offerwall
v1.0.1
Published
React Native wrapper for PubScale Offerwall SDK (Android only)
Maintainers
Readme
react-native-pubscale-offerwall
React Native wrapper for the PubScale Offerwall SDK. Android only — iOS returns safe no-ops (no crashes, no errors).
Features
- Native Android bridge for PubScale Offerwall SDK v1.0.11
- Promise-based TypeScript API
- Expo config plugin for automatic native setup
- iOS safe — all methods are no-ops on iOS
- ProGuard rules included automatically
Prerequisites
- React Native >= 0.73.0
- React >= 18.0.0
- Expo >= 50.0.0 (optional, for config plugin)
- Register your app on the PubScale Dashboard to get your 8-digit app ID
Installation
# npm
npm install react-native-pubscale-offerwall
# yarn
yarn add react-native-pubscale-offerwallExpo Setup
Add the plugin to your app.json or app.config.js:
{
"expo": {
"plugins": [
"react-native-pubscale-offerwall"
]
}
}Then rebuild native code:
npx expo prebuild --clean
npx expo run:androidBare React Native Setup
The package auto-links via React Native's autolinking. Just rebuild:
cd android && ./gradlew clean && cd ..
npx react-native run-androidUsage
import {
init,
launch,
destroy,
isAvailable,
} from 'react-native-pubscale-offerwall';
// 1. Check platform availability
if (isAvailable()) {
// 2. Initialize with your app ID
await init('YOUR_APP_ID', {
user_id: 'user-123', // optional: for S2S callbacks
sandbox: true, // optional: enable for testing
});
// 3. Launch the offerwall
const reward = await launch();
if (reward) {
console.log('Reward:', reward.amount, reward.currency, reward.token);
}
// 4. Cleanup when done
destroy();
}API Reference
isAvailable(): boolean
Returns true on Android when the native module is linked. Always returns false on iOS/Web.
init(appId, params?): Promise<void>
Initializes the PubScale Offerwall SDK. Must be called before launch().
| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| appId | string | Yes | Your 8-digit PubScale app ID |
| params.user_id | string | No | User identifier for S2S callbacks |
| params.sandbox | boolean | No | Enable sandbox mode for testing |
| params.fullscreen | boolean | No | Show offerwall in fullscreen |
| params.background_Base64 | string | No | Base64 encoded banner background image |
| params.appicon_Base64 | string | No | Base64 encoded app icon for banner |
On iOS, resolves immediately (no-op).
launch(): Promise<PubscaleOfferwallReward | null>
Launches the offerwall UI. Resolves when the user closes the offerwall.
Returns a PubscaleOfferwallReward if a reward was claimed:
interface PubscaleOfferwallReward {
amount: number;
currency: string;
token: string;
}Returns null if no reward was claimed or on iOS.
destroy(): void
Cleans up SDK resources. Call when you no longer need the offerwall. No-op on iOS.
Platform Support
| Platform | Supported | |----------|-----------| | Android | Yes | | iOS | No (safe no-op) | | Web | No (safe no-op) |
Testing
Enable sandbox mode during development:
await init('YOUR_APP_ID', { sandbox: true });Test on a physical Android device for best results. The SDK may not work on emulators.
License
MIT
