adstart_flutter_sdk 0.1.0 copy "adstart_flutter_sdk: ^0.1.0" to clipboard
adstart_flutter_sdk: ^0.1.0 copied to clipboard

Flutter SDK for Adstart event collection.

example/adstart_flutter_sdk_example.dart

import 'package:adstart_flutter_sdk/adstart_flutter_sdk.dart';
import 'package:firebase_core/firebase_core.dart';
import 'package:flutter/widgets.dart';

Future<void> main() async {
  WidgetsFlutterBinding.ensureInitialized();
  // The integrating app owns the Firebase configuration for its business.
  await Firebase.initializeApp();

  final adstart = AdstartSdk(hashedId: 'your-hashed-id');
  final sessionId = await adstart.init(
    onPushEvent: (event) {
      switch (event.type) {
        case AdstartPushEventType.received:
          debugPrint('Push received: ${event.notification?.title}');
        case AdstartPushEventType.opened:
          debugPrint('Push opened: ${event.deepLink}');
      }
    },
  );

  // Trigger this only from an explicit user action.
  await adstart.requestPushPermission();

  await adstart.customerIdentified(
    CustomerIdentificationEventParams(
      email: 'customer@example.com',
      customerExternalId: 'customer-123',
    ),
  );

  final product = AdstartItem(
    itemId: 'product-123',
    itemName: 'Product name',
    price: 249.90,
    itemBrand: 'Brand name',
    itemCategory: 'Category name',
  );
  final ecommerceParams = EcommerceEventParams(
    currency: 'BRL',
    items: <AdstartItem>[product],
  );

  await adstart.productViewed(ecommerceParams);
  await adstart.addProductToCart(ecommerceParams);
  await adstart.categoryViewed(name: 'Category name');
  await adstart.brandViewed(name: 'Brand name');
  await adstart.searchedFor(searchTerm: 'black shoes');

  debugPrint('Adstart session: $sessionId');
  adstart.dispose();
}
0
likes
0
points
298
downloads

Publisher

unverified uploader

Weekly Downloads

Flutter SDK for Adstart event collection.

Homepage
Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

crypto, firebase_core, firebase_messaging, flutter, http, shared_preferences, uuid

More

Packages that depend on adstart_flutter_sdk