trackier_sdk_flutter 1.6.60 trackier_sdk_flutter: ^1.6.60 copied to clipboard
This is trackier flutter SDK
import 'dart:ffi';
import 'package:flutter/material.dart';
import 'dart:async';
import 'package:flutter/services.dart';
import 'package:trackier_sdk_flutter/trackierfluttersdk.dart';
import 'package:trackier_sdk_flutter/trackierconfig.dart';
import 'package:trackier_sdk_flutter/trackierevent.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
String _platformVersion = 'Unknown';
@override
void initState() {
super.initState();
initPlatformState();
}
// Platform messages are asynchronous, so we initialize in an async method.
Future<void> initPlatformState() async {
TrackerSDKConfig trackerSDKConfig = new TrackerSDKConfig(
"ee9f21fb-5848-4ed9-8d9c-e4093e6d220c", "development");
//trackerSDKConfig.setManualMode(true);
//trackerSDKConfig.disableOrganicTracking(false);
trackerSDKConfig.deferredDeeplinkCallback = (uri){
print('The value of deeplinkUrl is: $uri');
};
// Trackierfluttersdk.updatePostbackConversion(0);
Trackierfluttersdk.setUserId("737263"); //Pass your userid
Trackierfluttersdk.setUserEmail("userEmail@gmail.com");
// var userAdditonalDetail = Map<String, Object>();
// userAdditonalDetail["phoneNumber"] = 9876453210;
//
// Trackierfluttersdk.setUserAdditonalDetail(userAdditonalDetail);
//Trackierfluttersdk.setLocalRefTrack(true, "_");
//Trackierfluttersdk.parseDeeplink("https://www.sanu.com");
Trackierfluttersdk.initializeSDK(trackerSDKConfig);
var trackierId = await Trackierfluttersdk.getTrackierId();
print('The value of trackierId is: $trackierId');
String platformVersion;
// Platform messages may fail, so we use a try/catch PlatformException.
// We also handle the message potentially returning null.
// try {
// platformVersion = await Trackierfluttersdk.platformVersion ??
// 'Unknown platform version';
// } on PlatformException {
// platformVersion = 'Failed to get platform version.';
// }
// If the widget was removed from the tree while the asynchronous platform
// message was in flight, we want to discard the reply rather than calling
// setState to update our non-existent appearance.
if (!mounted) return;
setState(() {
// _platformVersion = platformVersion;
});
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: Text('Trackier Flutter Sample App'),
),
body: Center(
child: Column(children: <Widget>[
TextButton(
style: TextButton.styleFrom(
primary: Colors.blue,
),
onPressed: () { _trackSimpleEvent();},
child: Text('Simple Events'),
),
// margin: EdgeInsets.all(25),
// child: FlatButton(
// child: Text(
// 'Track Event',
// style: TextStyle(fontSize: 20.0),
// ),
// color: Colors.cyan,
// textColor: Colors.black,
// onPressed: _trackSimpleEvent,
//),
Container(
// margin: EdgeInsets.all(25),
// child: FlatButton(
// child: Text(
// 'Track Revenue Event',
// style: TextStyle(fontSize: 20.0),
// ),
// color: Colors.cyan,
// textColor: Colors.black,
// onPressed: _trackRevenueEvent,
// ),
),
]))),
);
}
_trackSimpleEvent() {
TrackierEvent trackierEvent = new TrackierEvent("1CFfUn3xEY");
Trackierfluttersdk.setUserId("798e9w8ew09e8"); // Pass your userId here
Trackierfluttersdk.setUserName("abc");
Trackierfluttersdk.setUserPhone("6562127727");
Gender gender = Gender.Male;
Trackierfluttersdk.setGender(gender);
Trackierfluttersdk.setDOB("12/12/2003");
trackierEvent.couponCode = "72378728372";
//Trackierfluttersdk.fireInstall()
Trackierfluttersdk.setIMEI("imei1", "iemi222");
Trackierfluttersdk.setMacAddress("88239823232");
var userData = Map<String, Object>();
userData["phoneNumber"] = 9876453210;
userData["name"] = "Test";
trackierEvent.evMap = userData;
Trackierfluttersdk.parseDeeplink("https://trackier58.u9ilnk.me/d/aKDqzm0Rbp");
Trackierfluttersdk.trackerEvent(trackierEvent);
}
_trackRevenueEvent() {
TrackierEvent trackierEvent = new TrackierEvent("1CFfUn3xEY");
trackierEvent.revenue = 10.0;
trackierEvent.currency = "INR";
trackierEvent.orderId = "orderID";
trackierEvent.param1 = "param1";
trackierEvent.param2 = "param2";
trackierEvent.discount = 2.0;
trackierEvent.couponCode = "test1";
Trackierfluttersdk.setUserName("abc");
Trackierfluttersdk.setUserPhone("6562127727");
trackierEvent.setEventValue("ev1", "eventValue1");
trackierEvent.setEventValue("ev2", 1);
Trackierfluttersdk.trackerEvent(trackierEvent);
}
}