appboxo_sdk 0.6.1 copy "appboxo_sdk: ^0.6.1" to clipboard
appboxo_sdk: ^0.6.1 copied to clipboard

A Flutter plugin to integrate the Appboxo for iOS and Android.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:appboxo_sdk/appboxo_sdk.dart';
import 'package:fluttertoast/fluttertoast.dart';

void main() => runApp(MyApp());

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  Future<void> Function()? subscription;

  @override
  void dispose() {
    subscription?.call();
    super.dispose();
  }

  @override
  void initState() {
    super.initState();
    Appboxo.setConfig("602248",
        userId: "24", multitaskMode: true, theme: 'light');
    //'multitaskMode' works only on Android. By default 'true', each miniapp appears as a task in the Recents screen.
    Appboxo.customEvents().listen((CustomEvent event) {
      print(event.toJson().toString());
      Fluttertoast.showToast(
        msg: event.payload["message"] ?? event.type,
        toastLength: Toast.LENGTH_SHORT,
        timeInSecForIosWeb: 1,
        backgroundColor: Colors.black,
        textColor: Colors.white,
        fontSize: 16.0,
      );
      Appboxo.sendEvent(event);
    });
    Appboxo.paymentEvents().listen((event) {
      event.status = "success";
      Appboxo.sendPaymentEvent(event);
    });

    Appboxo.miniapps().listen((result) {
      print('miniapps - ${result.miniapps.toString()}');
      result.miniapps?.forEach((data) => print(data.name));
      print('error - ${result.error}');
    });
    Appboxo.getMiniapps();

    subscription = Appboxo.lifecycleHooksListener(
      onAuth: (appId) {
        print(appId);
        print('onAuth');
      },
      onLaunch: (appId) {
        print(appId);
        print('onLaunch');
      },
      onResume: (appId) {
        print(appId);
        print('onResume');
      },
      onPause: (appId) {
        print(appId);
        print('onPause');
      },
      onClose: (appId) {
        print(appId);
        print('onClose');
      },
      onError: (appId, error) {
        print(appId);
        print(error);
        print('onError');
      },
    );
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Appboxo SDK Test'),
        ),
        body: Center(
          child: ElevatedButton(
            onPressed: () {
              Appboxo.openMiniapp("app16973",
                  data: {'title': 'Title'},
                  extraUrlParams: {'key': 'value'},
                  colors: {
                    'primary_color': '#000000',
                    'secondary_color': '#0000FF',
                    'tertiary_color': '#00FF00'
                  },
                  enableSplash: false);
            },
            child: const Text(
              'Run miniapp',
              style: const TextStyle(
                color: Colors.white,
                fontSize: 16,
              ),
            ),
          ),
        ),
      ),
    );
  }
}
3
likes
130
points
66
downloads

Publisher

verified publisherappboxo.com

Weekly Downloads

A Flutter plugin to integrate the Appboxo for iOS and Android.

Homepage

Documentation

API reference

License

Apache-2.0 (license)

Dependencies

flutter

More

Packages that depend on appboxo_sdk