appier_flutter 2.0.0-dev.1
appier_flutter: ^2.0.0-dev.1 copied to clipboard
Flutter Plugin for Appier Enterprise Solutions. This plugin is intended to be used by any Appier customer. It supports tracking event logs, user profiles and device related data, and also supports ver [...]
import 'package:appier_flutter/appier_flutter.dart';
import 'package:flutter/material.dart';
void main() {
runApp(MaterialApp(
title: 'Appier Demo',
initialRoute: '/',
routes: {
'/': (context) => MainApp(),
'/second': (context) => FeedbackPage(),
},
));
}
class MainApp extends StatefulWidget {
const MainApp({Key? key}) : super(key: key);
@override
_MainAppState createState() => _MainAppState();
}
// add your app id before running in iOS
const appId = '<your_AppId>';
// add your app group before running in iOS
const appGroup = '<your_app_group>';
const appUniversalLink = 'universal-link';
class _MainAppState extends State<MainApp> {
@override
void initState() {
super.initState();
AppierFlutter.configure(appId, appGroup: appGroup, isDev: true);
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: Text('Plugin example app'),
),
body: Center(
child: ListView(
padding: EdgeInsets.all(8),
children: <Widget>[
SizedBox(
height: 44,
child: ElevatedButton(
style: ElevatedButton.styleFrom(
primary: Colors.teal[100],
onPrimary: Colors.black,
),
onPressed: () {
AppierFlutter.logEvent(
'product_viewed',
parameters: <String, dynamic>{
'param1': 2,
'param2': null,
'param3': 'appier',
},
);
},
child: Text('Log Event - product_viewed'),
),
),
SizedBox(
height: 44,
child: ElevatedButton(
style: ElevatedButton.styleFrom(
primary: Colors.teal[200],
onPrimary: Colors.black,
),
onPressed: () {
AppierFlutter.logEvent(
'product_add_to_cart',
parameters: <String, dynamic>{
'param1': 2,
'param2': null,
'param3': 'appier',
},
);
},
child: Text('Log Event - product_add_to_cart'),
),
),
SizedBox(
height: 44,
child: ElevatedButton(
style: ElevatedButton.styleFrom(
primary: Colors.teal[100],
onPrimary: Colors.black,
),
onPressed: () {
AppierFlutter.logEvent(
'product_purchased',
parameters: <String, dynamic>{
'param1': 2,
'param2': null,
'param3': 'appier',
},
vts: 100,
vtsCurr: 'USD',
);
},
child: Text('Log Event - product_purchased'),
),
),
SizedBox(
height: 44,
child: ElevatedButton(
style: ElevatedButton.styleFrom(
primary: Colors.teal[200],
onPrimary: Colors.black,
),
onPressed: () {
AppierFlutter.setUniversalLinkDomains([]);
AppierFlutter.setUniversalLinkDomains([appUniversalLink]);
},
child: Text('Set UniversalLinkDomains - iOS only'),
),
),
SizedBox(
height: 44,
child: ElevatedButton(
style: ElevatedButton.styleFrom(
primary: Colors.teal[100],
onPrimary: Colors.black,
),
onPressed: AppierFlutter.flush,
child: Text('flush log immediately'),
),
),
SizedBox(
height: 44,
child: ElevatedButton(
style: ElevatedButton.styleFrom(
primary: Colors.teal[200],
onPrimary: Colors.black,
),
onPressed: () {
AppierFlutter.setUserId('');
AppierFlutter.setUserId('0123456789');
},
child: Text('Set UserId'),
),
),
SizedBox(
height: 44,
child: ElevatedButton(
style: ElevatedButton.styleFrom(
primary: Colors.teal[100],
onPrimary: Colors.black,
),
onPressed: () {
AppierFlutter.setName('');
AppierFlutter.setName('tester');
},
child: Text('Set Name'),
),
),
SizedBox(
height: 44,
child: ElevatedButton(
style: ElevatedButton.styleFrom(
primary: Colors.teal[200],
onPrimary: Colors.black,
),
onPressed: () {
AppierFlutter.setFirstName('');
AppierFlutter.setFirstName('Gary');
},
child: Text('Set FirstName'),
),
),
SizedBox(
height: 44,
child: ElevatedButton(
style: ElevatedButton.styleFrom(
primary: Colors.teal[100],
onPrimary: Colors.black,
),
onPressed: () {
AppierFlutter.setLastName('');
AppierFlutter.setLastName('Wu');
},
child: Text('Set LastName'),
),
),
SizedBox(
height: 44,
child: ElevatedButton(
style: ElevatedButton.styleFrom(
primary: Colors.teal[200],
onPrimary: Colors.black,
),
onPressed: () {
AppierFlutter.setCity('');
AppierFlutter.setCity('London');
},
child: Text('Set City'),
),
),
SizedBox(
height: 44,
child: ElevatedButton(
style: ElevatedButton.styleFrom(
primary: Colors.teal[100],
onPrimary: Colors.black,
),
onPressed: () {
AppierFlutter.setEmail('');
AppierFlutter.setEmail('test.test@gmail.com');
},
child: Text('Set Email'),
),
),
SizedBox(
height: 44,
child: ElevatedButton(
style: ElevatedButton.styleFrom(
primary: Colors.teal[200],
onPrimary: Colors.black,
),
onPressed: () {
AppierFlutter.setPhoneNumber('');
AppierFlutter.setPhoneNumber('028865252');
},
child: Text('Set PhoneNumber'),
),
),
SizedBox(
height: 44,
child: ElevatedButton(
style: ElevatedButton.styleFrom(
primary: Colors.teal[100],
onPrimary: Colors.black,
),
onPressed: () {
AppierFlutter.setDayOfBirth(0);
AppierFlutter.setDayOfBirth(29);
},
child: Text('Set DayOfBirth'),
),
),
SizedBox(
height: 44,
child: ElevatedButton(
style: ElevatedButton.styleFrom(
primary: Colors.teal[200],
onPrimary: Colors.black,
),
onPressed: () {
AppierFlutter.setMonthOfBirth(0);
AppierFlutter.setMonthOfBirth(12);
},
child: Text('Set MonthOfBirth'),
),
),
SizedBox(
height: 44,
child: ElevatedButton(
style: ElevatedButton.styleFrom(
primary: Colors.teal[100],
onPrimary: Colors.black,
),
onPressed: () {
AppierFlutter.setYearOfBirth(12);
AppierFlutter.setYearOfBirth(0);
},
child: Text('Set YearOfBirth'),
),
),
SizedBox(
height: 44,
child: ElevatedButton(
style: ElevatedButton.styleFrom(
primary: Colors.teal[200],
onPrimary: Colors.black,
),
onPressed: () {
AppierFlutter.setCustomKey('Weight', 100);
AppierFlutter.setCustomKey('NickName', false);
AppierFlutter.setCustomKey('Height', 169.9);
AppierFlutter.setCustomKey('District', 'XinYi');
},
child: Text('Set CustomKeyValue'),
),
),
SizedBox(
height: 44,
child: ElevatedButton(
style: ElevatedButton.styleFrom(
primary: Colors.teal[100],
onPrimary: Colors.black,
),
onPressed: () {
AppierFlutter.setAttributionWindow(100);
},
child: Text('Set AttributionWindow'),
),
),
SizedBox(
height: 44,
child: ElevatedButton(
style: ElevatedButton.styleFrom(
primary: Colors.teal[200],
onPrimary: Colors.black,
),
onPressed: () {
AppierFlutter.setClickAttributionWindow(100);
},
child: Text('Set ClickAttributionWindow'),
),
),
],
),
),
floatingActionButton: FloatingActionButton(
onPressed: () {
// Add your onPressed code here!
Navigator.pushNamed(context, '/second');
},
backgroundColor: Colors.yellow,
child: Icon(Icons.feedback),
),
),
);
}
}
class FeedbackPage extends StatelessWidget {
const FeedbackPage({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Feedback Page'),
),
body: Center(
child: ElevatedButton(
onPressed: () {
AppierFlutter.logEvent('feedback');
},
child: Text('Log Feedback Event'),
),
),
);
}
}