Android offerwall SDK. Native, in a few lines of Kotlin.
Open the Moonetix offerwall as a native screen in your Android app. Install one Gradle dependency, create a session on your server, and call open. Works from Kotlin, Java, and Jetpack Compose.
- 5.0+Android, API 21
- 2.0.0Current version
- 0Extra permissions
// Once, in your Application class
Moonetix.init(applicationContext, "YOUR_APP_ID")
// When the user taps Earn
Moonetix.open(activity, token)Go live in four steps.
Copy the code, replace the placeholders with the values from your dashboard under Apps, your app, Integration, and test before you launch.
-
Install the SDK
Add the Moonetix Maven repository and one dependency. The SDK adds the internet permission and its screen to your manifest by itself, and brings its own R8 and ProGuard rules.
settings.gradle.ktsdependencyResolutionManagement { repositories { google() mavenCentral() maven { url = uri("https://moonetix.com/maven") } } } // app/build.gradle.kts dependencies { implementation("com.moonetix:offerwall:2.0.0") }settings.gradledependencyResolutionManagement { repositories { google() mavenCentral() maven { url 'https://moonetix.com/maven' } } } // app/build.gradle dependencies { implementation 'com.moonetix:offerwall:2.0.0' } -
Add a token endpoint to your server
Your app never holds the API key. When a user taps Earn, your app asks your server for a session, and your server asks Moonetix for a single-use token for that signed-in user. A token works once, for 10 minutes.
session.php<?php // POST /api/moonetix/session: a fresh token for the signed-in user $user = current_user(); if (!$user) { http_response_code(401); exit; } $key = getenv('MOONETIX_API_KEY'); $ch = curl_init('https://api.moonetix.com/v1/session'); curl_setopt_array($ch, [ CURLOPT_POST => true, CURLOPT_POSTFIELDS => http_build_query(['user_id' => (string)$user->id]), CURLOPT_RETURNTRANSFER => true, CURLOPT_TIMEOUT => 10, CURLOPT_HTTPHEADER => ['Authorization: Bearer ' . $key], ]); $data = json_decode((string)curl_exec($ch), true); $code = (int)curl_getinfo($ch, CURLINFO_RESPONSE_CODE); header('Content-Type: application/json'); if ($code === 201 && !empty($data['token'])) { echo json_encode(['token' => $data['token']]); exit; } http_response_code($code === 403 ? 403 : 503); echo json_encode(['error' => 'offerwall_unavailable']);session.js// POST /api/moonetix/session: a fresh token for the signed-in user app.post('/api/moonetix/session', requireLogin, async (req, res) => { const r = await fetch('https://api.moonetix.com/v1/session', { method: 'POST', headers: { Authorization: `Bearer ${process.env.MOONETIX_API_KEY}`, 'Content-Type': 'application/json', }, body: JSON.stringify({ user_id: String(req.user.id) }), signal: AbortSignal.timeout(10000), }); const data = await r.json().catch(() => ({})); if (r.status === 201 && data.token) { return res.json({ token: data.token }); } const status = r.status === 403 ? 403 : 503; res.status(status).json({ error: 'offerwall_unavailable' }); });session.py# POST /api/moonetix/session: a fresh token for the signed-in user @app.post("/api/moonetix/session") @login_required def moonetix_session(): key = os.environ["MOONETIX_API_KEY"] r = requests.post( "https://api.moonetix.com/v1/session", data={"user_id": str(current_user.id)}, headers={"Authorization": f"Bearer {key}"}, timeout=10, ) data = r.json() if r.status_code == 201 and data.get("token"): return {"token": data["token"]} status = 403 if r.status_code == 403 else 503 return {"error": "offerwall_unavailable"}, status -
Open the offerwall
Call init once with the App ID from your dashboard, then open the offerwall with the token from your server. Errors never throw: they arrive as events, and onClosed is a good moment to refresh the user’s balance.
EarnActivity.ktMoonetix.init(applicationContext, "YOUR_APP_ID") Moonetix.setListener(object : MoonetixListener { override fun onClosed() { refreshBalance() } override fun onError(error: MoonetixError) { Log.w("Earn", "${error.code}: ${error.message}") } }) lifecycleScope.launch { val token = fetchMoonetixToken(authToken) Moonetix.open(this@EarnActivity, token) }EarnActivity.javaMoonetix.init(getApplicationContext(), "YOUR_APP_ID"); // with a fresh token from your server Moonetix.open(activity, token);EarnButton.kt@Composable fun EarnButton(authToken: String) { val context = LocalContext.current val scope = rememberCoroutineScope() Button(onClick = { scope.launch { val token = runCatching { fetchMoonetixToken(authToken) } .getOrNull() ?: return@launch context.findActivity()?.let { Moonetix.open(it, token) } } }) { Text("Earn coins") } } -
Credit rewards with the postback
Every reward reaches your server as a signed postback. Check the hash, add the reward once per transaction ID, and take it back if a later postback reverses it. Failed postbacks are retried up to 5 times.
Dashboard, Postback tabhttps://yoursite.com/postback?user={user_id}&tx={transaction_id}&status={status}&reward={reward}&hash={hash}postback.php<?php $tx = $_GET['tx'] ?? ''; $userId = $_GET['user'] ?? ''; $reward = $_GET['reward'] ?? ''; $status = $_GET['status'] ?? ''; $secret = getenv('MOONETIX_POSTBACK_SECRET'); $expected = hash_hmac('sha256', "$tx:$userId:$reward:$status", $secret); if (!hash_equals($expected, $_GET['hash'] ?? '')) { http_response_code(403); exit; } if ($status === '1') { credit_once($userId, $tx, $reward); // once per transaction ID } elseif ($status === '2') { reverse_if_credited($userId, $tx, $reward); } http_response_code(200);postback.jsconst crypto = require('crypto'); app.get('/postback', (req, res) => { const { tx, user, reward, status, hash } = req.query; const secret = process.env.MOONETIX_POSTBACK_SECRET; const expected = crypto.createHmac('sha256', secret) .update(`${tx}:${user}:${reward}:${status}`) .digest('hex'); const valid = typeof hash === 'string' && hash.length === expected.length && crypto.timingSafeEqual(Buffer.from(hash), Buffer.from(expected)); if (!valid) return res.sendStatus(403); if (status === '1') creditOnce(user, tx, reward); // once per transaction ID if (status === '2') reverseIfCredited(user, tx, reward); res.sendStatus(200); });postback.pyimport hmac, hashlib, os from flask import request, abort @app.get("/postback") def postback(): a = request.args parts = [a.get(k, "") for k in ("tx", "user", "reward", "status")] msg = ":".join(parts) secret = os.environ["MOONETIX_POSTBACK_SECRET"].encode() expected = hmac.new(secret, msg.encode(), hashlib.sha256).hexdigest() if not hmac.compare_digest(expected, a.get("hash", "")): abort(403) if a.get("status") == "1": credit_once(a["user"], a["tx"], a["reward"]) # once per transaction ID elif a.get("status") == "2": reverse_if_credited(a["user"], a["tx"], a["reward"]) return "", 200
- Castle MergeReach level 10+1,500
- FitTrackStart a free trial+2,000
- Word RushPlay 3 days in a row+450
- Budget PalSet up your first budget+800
What your users see
A native screen over your app, with your title and colors, your currency, and every reward confirmed by a postback.
What the SDK handles for you
- Offers open in the right place
Offers that lead to Google Play open in the store app, and other sites open in the browser, so installs are tracked correctly.
- No key inside your app
Your app holds only the App ID. Sessions are created on your server and work once, so nobody can open the offerwall as another user.
- A locked-down screen
Only offerwall pages load inside it, with no JavaScript bridge into your app.
- Native navigation
The back button goes back inside the offerwall, and screen rotation or a low-memory restart keeps the user where they were.
- Your design, no extra code
The screen uses the title and colors from the Design tab of your dashboard, and picks up changes within a few minutes.
- No advertising ID
The SDK does not use the advertising identifier and does not track users across apps.
Test it, then launch.
Everything you need to check before real users see your offerwall, with the tools built into your dashboard.
Open as a test user
In Integration status on the Integration tab, open your offerwall as the user owner-test. Test visits are not counted as users.
Run it on a real device
Build for Android or iOS and open the offerwall from your Earn button with a fresh token each time.
Send a test postback
Choose the user, status, and payout, and see exactly what your server answered, with the response code and time. Test transaction IDs start with test_.
Test from a normal connection
VPNs, proxies, Tor, and cloud networks are blocked, so test on home Wi-Fi or mobile data, in a country where offers run.
Launch checklist
0 of 11 ready
Ready to launch. Your progress is saved in this browser.
Common errors, fixed fast.
What you might see while you integrate the Android SDK, what causes it, and the fix.
INVALID_APP_IDThe value passed to init is not the App ID. Passing the API key here is the most common mistake.
FixCopy the 24-character App ID again from the Integration tab.
INVALID_TOKENThe app passed something other than the token, or a token created with the API key of another app.
FixPass only the token field, which starts with sst_, and use the App ID and API key of the same app.
TOKEN_EXPIRED_OR_USEDThe token is older than 10 minutes or was already used, for example kept from an earlier tap.
FixCreate a new token for every open, right when the user taps Earn.
NOT_INITIALIZEDopen was called before init.
FixCall Moonetix.init in Application.onCreate.
UNKNOWNAndroid System WebView is missing or turned off, or the Activity you passed was already closing.
FixAsk the user to update Android System WebView, and pass an Activity that is on screen.
onClosed never arrivesThe listener was cleared in onStop, or it belonged to a screen that is gone.
FixSet it in onCreate and clear it in onDestroy, or set it once in your Application.
403 from /v1/sessionapp_not_live means the app is paused or your account is not active. user_blocked means we blocked this user.
FixDo not show the offerwall. For app_not_live, check your notifications.
VPN or Proxy detectedThe device is on a VPN, a proxy, or a cloud network, where offers cannot be tracked.
FixTest on a normal home or mobile connection, in a country where offers run.
Postback log shows 403 or 404Your script rejected the postback, or the URL is wrong.
FixOpen the URL from the log in a browser and check your hash code.
Postback log shows a timeoutYour script takes longer than 6 seconds to answer.
FixAnswer with 200 first, and run slow work in the background.
Postback log shows 301 or 302Your URL redirects, for example from http to https.
FixUse the final URL. Postbacks do not follow redirects.
No match. See the full list in the docs or contact us.
At a glance
- Minimum version
- Android 5.0 (API 21), with Android System WebView or Chrome
- Languages
- Kotlin, Java, and Jetpack Compose
- Package
- com.moonetix:offerwall:2.0.0 from moonetix.com/maven
- Dependencies
- Only the Kotlin standard library
- Permissions
- Internet only, added by the SDK
- Price
- Free for approved publishers
Other integrations
- WebsiteA link, an iframe, or a floating Earn button. No SDK needed.
- Offers APIGet the offers as JSON and show them in your own design.
- iOS SDKA native offerwall for Swift, SwiftUI, and Objective-C.
- Unity SDKRewarded offers for Android and iOS games, from C#.
- Flutter SDKOne Dart plugin for Android and iOS.
- React Native SDKFor React Native and Expo apps, with TypeScript types.
- All integrationsCompare them side by side.
Android questions
What developers ask before they add the Android SDK.
Stuck on something? Contact us
Which Android versions does the Moonetix SDK support?
Android 5.0 (API 21) or newer, with Android System WebView or Chrome on the device. The only dependency is the Kotlin standard library, so it works in Kotlin and Java apps.
Do I need to add ProGuard or R8 rules?
No. The SDK brings its own R8 and ProGuard rules, and it adds the internet permission and its offerwall screen to your manifest by itself.
Does my API key go into the app?
No. Your app only holds the App ID. Your server creates a session with the API key and passes a token to the app. A token works once and for 10 minutes, so nothing in your app can open another user’s offerwall.
Does the SDK use the advertising ID?
No. It does not use the advertising ID, asks for no permission other than internet access, and does not track users across apps. The docs list what to declare in the Google Play Data safety form.
How do I reward users in my app?
Credit rewards from the signed postback on your server, never from events in the app, because events can be faked on a device. When the user closes the offerwall, load their new balance from your server.
Can the offerwall screen match my app?
Yes. It uses the title and colors from the Design tab of your dashboard. You can also pass your own title, toolbar color, or hide the mark with MoonetixOptions.
Turn your traffic into earnings.
Create a free publisher account and earn from every offer your users complete on your website, app, game, or community.