umeng_common_sdk.dart 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. import 'dart:async';
  2. import 'package:flutter/services.dart';
  3. class UmengCommonSdk {
  4. static const MethodChannel _channel =
  5. const MethodChannel('umeng_common_sdk');
  6. static Future<String> get platformVersion async {
  7. final String version = await _channel.invokeMethod('getPlatformVersion');
  8. return version;
  9. }
  10. static Future<dynamic> initCommon(String androidAppkey, String iosAppkey, String channel) async {
  11. List<dynamic> params = [androidAppkey, iosAppkey ,channel];
  12. final dynamic result = await _channel.invokeMethod('initCommon', params);
  13. return result;
  14. }
  15. static void onEvent(String event, Map<String,dynamic> properties) {
  16. List<dynamic> args = [event,properties];
  17. _channel.invokeMethod('onEvent', args);
  18. }
  19. static void onProfileSignIn (String userID) {
  20. List<dynamic> args = [userID];
  21. _channel.invokeMethod('onProfileSignIn', args);
  22. }
  23. static void onProfileSignOff () {
  24. _channel.invokeMethod('onProfileSignOff');
  25. }
  26. static void setPageCollectionModeManual() {
  27. _channel.invokeMethod('setPageCollectionModeManual');
  28. }
  29. static void onPageStart(String viewName) {
  30. List<dynamic> args = [viewName];
  31. _channel.invokeMethod('onPageStart', args);
  32. }
  33. static void onPageEnd(String viewName) {
  34. List<dynamic> args = [viewName];
  35. _channel.invokeMethod('onPageEnd', args);
  36. }
  37. static void setPageCollectionModeAuto() {
  38. _channel.invokeMethod('setPageCollectionModeAuto');
  39. }
  40. static void reportError(String error) {
  41. List<dynamic> args = [error];
  42. _channel.invokeMethod('reportError', args);
  43. }
  44. }