trackier_sdk_flutter 1.6.61 trackier_sdk_flutter: ^1.6.61 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( // simulator app - ee9f21fb-5848-4ed9-8d9c-e4093e6d220c
"b551b474-e91c-470e-900b-971e5b954169", "development"); // tic tac toe - b551b474-e91c-470e-900b-971e5b954169
//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(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
TextButton(
style: TextButton.styleFrom(
// primary: Colors.blue,
),
onPressed: _trackSimpleEvent,
child: Text('Simple Events'),
),
TextButton(
style: TextButton.styleFrom(
// primary: Colors.blue,
),
onPressed: _trackRevenueEvent,
child: Text('Revenue Events'),
),
],
),
),
),
);
}
/* Future<void> initUniLinks() async {
// Get the initial uri that was used to start the app
try {
_initialUri = await getInitialUri();
// Attach a listener to the uri stream
_sub = uriLinkStream.listen((Uri? uri) {
setState(() {
_currentUri = uri;
});
}, onError: (err) {
// Handle any errors here
});
// Get the action if the app was opened with an action intent
_action = await getInitialLink();
} on FormatException catch (e) {
// Handle exception when parsing the URI
print('Error parsing URI: $e');
} on Exception catch (e) {
// Handle general errors
print('Error: $e');
}
}*/
_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);
}
}