dmhubsdk 1.0.9 dmhubsdk: ^1.0.9 copied to clipboard
Dmhub Flutter project.
import 'package:flutter/material.dart';
import 'dart:async';
import 'package:dmhubsdk/dmhubsdk.dart';
void main() {
WidgetsFlutterBinding.ensureInitialized();
var options = DMHubOptions(
trackUrl: 'https://xxxxx/cbe/track?tid=xxxx',
appId: 'appId',
appName: 'FlutterDemo');
options.autoTrackOpenAppEvent = true;
options.enableDebugLogging = true;
options.flushInterval = 40;
// 禁用 androidId、idfa、location信息(定位)、mac 的采集
options.disableCollect = [
DMHubOptions.COLLECT_ANDROID_ID,
DMHubOptions.COLLECT_IDFA,
DMHubOptions.COLLECT_LOCATION,
DMHubOptions.COLLECT_MAC
];
DMHubClient.getInstance.init(options).then((value) => null);
// 禁用对imei采集
DMHubClient.getInstance.disableCollect([DMHubOptions.COLLECT_IMEI]);
// 启用对定位的采集
DMHubClient.getInstance.enableCollect([DMHubOptions.COLLECT_MAC]);
DMHubClient.getInstance
.setIdentity("身份证", "51028xxxxxxxxxxx299")
.then((value) => null);
Map<String, dynamic> mapPush = {
'appKey': '4x33fbdafdif',
'pushId': '55444378x',
'provider': "这是测试的数据"
};
DMHubClient.getInstance.onGlobalParamsPush(mapPush);
//
DMHubClient.getInstance.currentIdentity().then((result) {
DMHubLog.v(result, tag: 'identityDmhub');
});
//
Map<String, dynamic> maProperties = {
'aa': '55555555',
'bb': '66666666',
};
DMHubClient.getInstance.trackMap('trackMap-44434333', maProperties);
//
DMHubClient.getInstance.track('track-4434333');
//
DMHubClient.getInstance.trackOpenView('FlutterViewController');
//
DMHubClient.getInstance.trackExitView('FlutterViewController');
DMHubClient.getInstance.onJPushReceiveRegisterId('443245454', 'fgfgfddfdfdf');
//
Map<String, dynamic> jpushMap = {
'aaddf': '55555555',
'bbdfdfd': '66666666',
};
DMHubClient.getInstance.onJPushReceiveMessageData(jpushMap);
jpushMap = {
'xabbdaddf': '55555555',
'xbbdddfdfd': '66666666',
};
DMHubClient.getInstance.onJPushNotificationMessageArrived(jpushMap);
//
DMHubClient.getInstance.onGeTuiReceiveClientId('fdxxxx', '333334433');
//
DMHubClient.getInstance.trackReceiveJPushMessage(jpushMap);
//
DMHubClient.getInstance.trackReceiveGeTuiPayloadData(jpushMap);
//
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 {
// String platformVersion;
// Platform messages may fail, so we use a try/catch PlatformException.
// We also handle the message potentially returning null.
// try {
// platformVersion =
// await Dmhubsdk.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: const Text('Plugin example app'),
),
body: Center(
child: Text('Running on: $_platformVersion\n'),
),
),
);
}
}