flutter_turbolink_attribution 1.0.6 copy "flutter_turbolink_attribution: ^1.0.6" to clipboard
flutter_turbolink_attribution: ^1.0.6 copied to clipboard

TurboLink's official Flutter SDK for App Attribution & Campaign.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:flutter_turbolink_attribution/flutter_turbolink_attribution.dart';
import 'package:flutter_turbolink_attribution/turbolink_custom_properties.dart';
import 'package:flutter_turbolink_attribution_example/login.dart';

final navigatorKey = GlobalKey<NavigatorState>();

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

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

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

class _MyAppState extends State<MyApp> {
  String _platformVersion = 'Unknown';

  @override
  void initState() {
    print("initState");
    super.initState();
    initTurbolinkSDK();

  }

  void initTurbolinkSDK() async {
    TurbolinkSdk.enableLogger();

    // TurbolinkSdk.setAppUser("jeff", "");
    TurbolinkSdk.setLang('zh');

    TurbolinkSdk.withCampaignCreateCallback((result) {
      print("TurboLinkSDK, withCampaignCreateCallback:" + result);
    });
    TurbolinkSdk.withCampaignDestroyCallback((result) {
      print("TurboLinkSDK, withCampaignDestroyCallback:" + result);
    });

    TurbolinkSdk.withLoginListenerCallback(() {
      print("TurboLinkSDK, withLoginListenerCallback:");
      navigatorKey.currentState?.push(MaterialPageRoute(builder: (context) => LoginWidget()));
    });
    TurbolinkSdk.withRegListenerCallback(() {
      print("TurboLinkSDK, withRegListenerCallback");
      navigatorKey.currentState?.push(MaterialPageRoute(builder: (context) => LoginWidget()));
    });
    TurbolinkSdk.withEventListenerCallback((args) {
      print("TurboLinkSDK, withEventListenerCallback:${args.arguments}:${args.scheme}:${args.campaignUrl}:${args.additionalParam}");
      TurbolinkSdk.closeCampaignPage();
    });
    TurbolinkSdk.withEventCallback((args) {
      print("TurboLinkSDK, withEventCallback:${args.linkHashId}:${args.blackBox}:${args.deviceStatus}:${args.linkData}");
    });
    TurbolinkSdk.withPointListenerCallback((args) {
      print("TurboLinkSDK, withPointListenerCallback: ${args.campaignTitle}:${args.campaignLang}:${args.campaignUrl}:${args.user}:${args.position}");
    });
    TurbolinkSdk.withShareListenerCallback((args) {
      print("TurboLinkSDK, withShareListenerCallback: ${args.sharingText}: ${args.shareText}: ${args.shareLink} :${args.noInstallPrompt}: ${args.targetScheme}: ${args.campaignId}");
    });

    TurbolinkSdk.withRedirectListenerCallback((args) {
      TurbolinkSdk.closeCampaignPage();
      print("TurboLinkSDK, withRedirectListenerCallback: ${args.campaignId}_${args.campaignTitle}_${args.campaignLang}_${args.campaignUrl}_${args.user}_${args.type}_${args.appUrl}_${args.rewardTitle}_${args.kvData.values}");
    });
    // TurbolinkSdk.setAppUser("ben", "v1");
    TurbolinkSdk.setScreenOrientationAll();
    TurbolinkSdk.setLaunchCampaignDelay(-1);
    TurbolinkSdk.setNightMode(true);
    TurbolinkSdk.setInitTitle("加入中");
    TurbolinkSdk.setTitleSize(16);
    TurbolinkSdk.setIdSimpleMode();
    TurbolinkSdk.autoInstance('coae59progtocgji0vug', '6fbbbbe1f68712212c895522d66c241e', '6f3c7c7c24d2ba6f0d53256968e56ea4b7b4bee8');
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      navigatorKey: navigatorKey,
      debugShowCheckedModeBanner: false,
      // home: MainWidget(_platformVersion),
      home: Builder(
        builder: (context) => Scaffold(
            appBar: AppBar(
              title: const Text('Plugin example app'),
            ),
            body: Column(
              children: [
                Container(
                  child: Text('Running on: $_platformVersion\n'),
                ),
                Container(
                  child: TextButton(
                    onPressed: (){
                      print("onPressed");
                      TurbolinkSdk.loadUrl("https://jeffapp.c.allapp.link/c?l=cq8a3310b4mgqmbh2e20&c=sj");
                      // Navigator.push(context,MaterialPageRoute(builder: (context) => LoginWidget()));
                    },
                    child: Text("活动"),
                  ),
                ),
                TextButton(
                  onPressed: () {
                    Navigator.push(context,MaterialPageRoute(builder: (context) => LoginWidget()));
                  },
                  child: Text("Login Widget"),
                ),
                TextButton(
                  onPressed: () {
                    TurbolinkSdk.logout();
                  },
                  child: Text("Logout"),
                ),
                TextButton(
                  onPressed: () {
                    TurboLinkCustomProperties customData = TurboLinkCustomProperties()
                        .addKeyValue("name", "ben")
                        .addKeyValue("age", "22");
                    TurbolinkSdk.customEvent("pay", customData);
                  },
                  child: Text("自定义事件"),
                ),
                TextButton(
                  onPressed: () {
                    TurbolinkSdk.register("jeff");
                  },
                  child: Text("register"),
                ),
                TextButton(
                  onPressed: () {
                    TurbolinkSdk.codeSearch("143.42¥8QJXKXOTv2¥");
                  },
                  child: Text("codeSearch"),
                ),
              ],
            )
        ),
      )
    );
  }
}
2
likes
140
pub points
52%
popularity

Publisher

unverified uploader

TurboLink's official Flutter SDK for App Attribution & Campaign.

Homepage

Documentation

API reference

License

MIT (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on flutter_turbolink_attribution