adbrixrm_flutter 1.4.0 copy "adbrixrm_flutter: ^1.4.0" to clipboard
adbrixrm_flutter: ^1.4.0 copied to clipboard

outdated

AdBrix Remastered plugin for Flutter project. AdBrix is a global Attribution and Analytics tool for Android and iOS app.

example/lib/main.dart

import 'dart:async';
import 'dart:io';

import 'package:adbrixrm_flutter/adbrixrm.dart';
import 'package:adbrixrm_flutter_example/commerceEvent.dart';
import 'package:adbrixrm_flutter_example/gameEvent.dart';
import 'package:adbrixrm_flutter_example/userInfoEvent.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';

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

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

class _MyAppState extends State<MyApp> with WidgetsBindingObserver {

  int _currentIndex = 0;
  List _page = [userInfoView(), commerceView(), gameView()];

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Center(
          child: _page[_currentIndex],
        ),
        bottomNavigationBar: BottomNavigationBar(
          fixedColor: Colors.blue,
          currentIndex: _currentIndex,
          onTap: onTabTapped,
          items: const <BottomNavigationBarItem>[
            BottomNavigationBarItem(icon: Icon(Icons.home), label: 'userinfo'),
            BottomNavigationBarItem(
                icon: Icon(Icons.credit_card), label: 'Commerce'),
            BottomNavigationBarItem(icon: Icon(Icons.gamepad), label: 'Game')
          ],
        ),
      ),
    );
  }

  @override
  void didChangeAppLifecycleState(AppLifecycleState currentState) {
    if (currentState == AppLifecycleState.resumed) {
      print("App is onResume");

      Timer(Duration(seconds: 3), () {
        getDeeplink();
      });
    }
  }

  Future<void> getDeeplink() async {
    String? deeplink = await AdBrixRm.adbrixDeeplink;

    if (deeplink != null) {
      print ("DeeplinkString ::::: " + deeplink);
    } else {
      print ("No Deeplink String from AdBrix");
    }

  }


  @override
  void initState() {
    super.initState();
    WidgetsBinding.instance!.addObserver(this);

    AdBrixRm.sdkInit(
        appKey: 'G2Iz74fLkUOcZPZTrZQnQw', secretKey: 'ZP1RO2EDY02kpifcIOlzGQ');

    Timer(Duration(seconds: 5), () {
      _getDeferredDeeplink();

      // Only Android Needed
      if (Platform.isAndroid) {
        getDeeplink();
      }

    });
  }

  Future _getDeferredDeeplink() async {
    String? deferredDeeplink = '';
    try {
      deferredDeeplink = await AdBrixRm.adbrixDeferredDeeplink;
      if(deferredDeeplink != null) {
        print("AdBrixRm Deferred Deeplink :::::: " + deferredDeeplink);

      } else {

        print("No AdBrixRm Deferred Deeplink");

      }
    } on PlatformException {
    }

    if(deferredDeeplink != null) {
      if(deferredDeeplink.isNotEmpty) {

      }
    }
  }

  void onTabTapped(int index) {
    switch (index) {
      case 0:
        AdBrixRm.events(eventName: 'userInfo');
        break;

      case 1:
        Map<String, dynamic> attr = <String, dynamic>{
          'int': 2,
          'string': 'this is commerce',
          'string2': 'this is String2',
          'double': 25000.00,
          'long': 2222222222222,
          'bool': false
        };
        AdBrixRm.events(eventName: 'commerce', attr: attr);
        break;

      case 2:
        Map<String, dynamic> attr = <String, dynamic>{
          'string': 'this is game',
          'int': 3,
          'bool': true,
          'long': 33333333333333,
          'double': 35000.00
        };

        AdBrixRm.events(eventName: 'game', attr: attr);

        break;
    }
    setState(() {
      _currentIndex = index;
    });
  }
}
4
likes
0
points
35
downloads

Publisher

verified publisherigaworks.com

Weekly Downloads

AdBrix Remastered plugin for Flutter project. AdBrix is a global Attribution and Analytics tool for Android and iOS app.

Homepage

License

unknown (license)

Dependencies

flutter

More

Packages that depend on adbrixrm_flutter

Packages that implement adbrixrm_flutter