1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import 'dart:async';
import 'package:flutter/foundation.dart';
import 'package:flutter/services.dart';
class UmengCommonSdk {
static const MethodChannel _channel = const MethodChannel('umeng_common_sdk');
///
/// 预初始化
/// [appKey] 友盟控制台appKey
/// [channel] app的渠道,如:应用宝、小米、华为应用商店等
/// [enableLog] 是否启用日志
///
static Future<bool> preInit({
@required String appKey,
@required String channel,
bool enableLog = false,
}) async {
final bool result = await _channel.invokeMethod('preInit', {
'appKey': appKey,
'channel': channel,
'enableLog': enableLog,
});
return result;
}
///
/// 初始化
/// [appKey] 友盟控制台appKey
/// [channel] app的渠道,如:应用宝、小米、华为应用商店等
/// [deviceType] 设备类型1、手机、2、...
/// [pushSecret] 密钥
///
static Future<bool> init({
@required String appKey,
@required String channel,
int deviceType = 1,
String pushSecret,
}) async {
final dynamic result = await _channel.invokeMethod('init', {
'appKey': appKey,
'channel': channel,
'deviceType': deviceType,
'pushSecret': pushSecret,
});
return result;
}
///
/// 上报事件
/// [event] 事件标志
/// [properties] 事件参数
///
static Future<bool> onEvent({
@required String event,
@required Map<String, dynamic> properties,
}) async {
return await _channel.invokeMethod('onEvent', {
'eventId': event,
'properties': properties,
});
}
}