Adjump
VersionHome Page
  • Adjump SDK Documentation
  • ANDROID
    • ๐Ÿ“ฒSDK Setup
    • โšกSDK Initialization
    • ๐Ÿ› ๏ธProGuard Rules
  • REACT NATIVE
    • ๐Ÿ“ฒSDK Setup
    • โšกSDK Initialization
    • ๐Ÿ› ๏ธProGuard Rules
  • Flutter
    • ๐Ÿ“ฒSDK Setup
    • โšกSDK Initialization
    • ๐Ÿ› ๏ธProGuard Rules
  • Payout
    • ๐Ÿ”ŒS2S Postback Setup
Powered by GitBook
On this page
  • ๐Ÿง‘โ€๐Ÿ’ป Integration Guide
  • ๐Ÿงช Testing
  • โ“ FAQ
  1. Flutter

SDK Initialization

๐Ÿง‘โ€๐Ÿ’ป Integration Guide

1. Android (Kotlin)

In your MainActivity.kt (inside android/):

package com.example.adjump

import android.content.Context
import android.util.Log
import android.widget.Toast
import io.flutter.embedding.android.FlutterActivity
import io.flutter.embedding.engine.FlutterEngine
import io.flutter.plugin.common.MethodChannel
import io.adjump.offerwall.AdJump

class MainActivity : FlutterActivity() {
    private val CHANNEL = "com.example.offerwall_app"
    private var adJump: AdJump? = null

    override fun configureFlutterEngine(flutterEngine: FlutterEngine) {
        super.configureFlutterEngine(flutterEngine)

        // Setup AdJump
        adJump = AdJump(this, "accountid", "appid", "userid")

        MethodChannel(flutterEngine.dartExecutor.binaryMessenger, CHANNEL)
            .setMethodCallHandler { call, result ->
                when (call.method) {
                    "launchOfferWall" -> {
                        launchOfferWall()
                        result.success("Offer wall launched")
                    }
                    else -> result.notImplemented()
                }
            }
    }

    private fun launchOfferWall() {
        adJump?.initialize(object : AdJump.InitialisationListener {
            override fun onInitialisationSuccess() {
                runOnUiThread { Toast.makeText(this@MainActivity, "AdJump SDK Initialized", Toast.LENGTH_SHORT).show() }
                // Show the offer wall
                if (adJump?.isAvailable == true) {
                    adJump?.launchOfferWall()
                } else {
                    Toast.makeText(this@MainActivity, "Offerwall not available!", Toast.LENGTH_SHORT).show()
                }
            }

            override fun onInitialisationError(exception: Exception) {
                runOnUiThread { Toast.makeText(this@MainActivity, "Initialization failed: ${exception.message}", Toast.LENGTH_SHORT).show() }
            }
        })
    }
}

2. Flutter Dart Code

In your main.dart file:

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  static const platform = MethodChannel('com.example.offerwall_app');

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(title: Text('Adjump Example')),
        body: Center(
          child: ElevatedButton(
            onPressed: _launchOfferWall,
            child: Text('Launch OfferWall'),
          ),
        ),
      ),
    );
  }

  Future<void> _launchOfferWall() async {
    try {
      await platform.invokeMethod('launchOfferWall');
    } on PlatformException catch (e) {
      print("Failed to show offer wall: '${e.message}'.");
    }
  }
}

๐Ÿงช Testing

  • Make sure you're running on a physical Android device or emulator with internet access.

  • Log output and Toast messages will indicate SDK initialization and errors.


โ“ FAQ

Q: Does it support iOS? A: No, this SDK currently supports Android only.

Q: Where do I get my accountid, appid, and userid? A: These are provided by the Adjump platform once you're onboarded.


PreviousSDK SetupNextProGuard Rules

Last updated 3 days ago

โšก