flutter_meta_appads_sdk 1.0.1 copy "flutter_meta_appads_sdk: ^1.0.1" to clipboard
flutter_meta_appads_sdk: ^1.0.1 copied to clipboard

This Flutter plugin provides a simple interface to interact with the Meta SDK. It allows you to initialize the SDK, set user data (Advanced Attribution), and log events/purchases.

example/lib/main.dart

import 'dart:async';

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

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

class MyApp extends StatefulWidget {
  const MyApp({super.key});

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  final _flutterMetaAppadsSdkPlugin = FlutterMetaAppAdsSdk();
  String? fbAnonId;

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
          appBar: AppBar(
            title: const Text('Plugin example app'),
          ),
          body: Column(
            children: [
              ElevatedButton(
                onPressed: () =>
                    unawaited(_flutterMetaAppadsSdkPlugin.initSdk()),
                child: const Text("Init SDK"),
              ),
              const SizedBox(
                height: 8,
              ),
              ElevatedButton(
                child: const Text("Get FB AnonId"),
                onPressed: () async {
                  var anonId = await _flutterMetaAppadsSdkPlugin.getFbAnonId();
                  setState(() {
                    fbAnonId = anonId;
                  });
                },
              ),
              Text("FB ANON ID: ${fbAnonId ?? "Not retrieved AnonId"}"),
              const SizedBox(
                height: 8,
              ),
              ElevatedButton(
                onPressed: () => unawaited(
                  _flutterMetaAppadsSdkPlugin.logEvents(
                    FBLogEventCommand(
                      eventName: "test_event",
                      eventParameters: {
                        "my_parameter": "1234",
                      },
                    ),
                  ),
                ),
                child: const Text("Log Event"),
              ),
              const SizedBox(
                height: 8,
              ),
              ElevatedButton(
                onPressed: () => unawaited(
                  _flutterMetaAppadsSdkPlugin.logStandardEvent(
                    FBLogStandardEventCommand(
                      event: FBStandardEvent.contact,
                      parameters: {
                        FBStandardParameter.parameterNameSuccess: "1",
                      },
                    ),
                  ),
                ),
                child: const Text("Log Standard Event"),
              ),
              const SizedBox(
                height: 8,
              ),
              ElevatedButton(
                onPressed: () => unawaited(
                  _flutterMetaAppadsSdkPlugin.logPurchase(
                    FBLogPurchaseCommand(
                      amount: 1,
                      currency: "USB",
                      eventParameter: {
                        "my_parameter": "1234",
                      },
                    ),
                  ),
                ),
                child: const Text("Log Purchase"),
              ),
              const SizedBox(
                height: 8,
              ),
              ElevatedButton(
                onPressed: () => unawaited(
                  _flutterMetaAppadsSdkPlugin.setUserData(
                    FBSetUserDataCommand(
                      type: FBUserDataType.country,
                      value:
                          "6959097001d10501ac7d54c0bdb8db61420f658f2922cc26e46d536119a31126",
                    ),
                  ),
                ),
                child: const Text("Set UserData"),
              ),
            ],
          )),
    );
  }
}
5
likes
0
points
172
downloads

Publisher

verified publishersergio.durban.cat

Weekly Downloads

This Flutter plugin provides a simple interface to interact with the Meta SDK. It allows you to initialize the SDK, set user data (Advanced Attribution), and log events/purchases.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter, plugin_platform_interface, protobuf

More

Packages that depend on flutter_meta_appads_sdk