Browse Source

推送跳转新增两个类型:COUPON(12)优惠券列表 CATE_BEAN(13)我的印章;

新增友盟统计数据;
new_revision_app
wurong 2 years ago
parent
commit
d1c963796b
  1. 7
      android/build.gradle
  2. 37
      lib/base_state.dart
  3. 33
      lib/main_page.dart
  4. 11
      pubspec.lock
  5. 5
      pubspec.yaml
  6. 15
      umeng_common_sdk-1.2.6/.gitignore
  7. 10
      umeng_common_sdk-1.2.6/.metadata
  8. 43
      umeng_common_sdk-1.2.6/CHANGELOG.md
  9. 1
      umeng_common_sdk-1.2.6/LICENSE
  10. 14
      umeng_common_sdk-1.2.6/README.md
  11. 8
      umeng_common_sdk-1.2.6/android/.gitignore
  12. 40
      umeng_common_sdk-1.2.6/android/build.gradle
  13. 3
      umeng_common_sdk-1.2.6/android/gradle.properties
  14. 1
      umeng_common_sdk-1.2.6/android/settings.gradle
  15. 3
      umeng_common_sdk-1.2.6/android/src/main/AndroidManifest.xml
  16. 214
      umeng_common_sdk-1.2.6/android/src/main/java/com/umeng/umeng_common_sdk/UmengCommonSdkPlugin.java
  17. 37
      umeng_common_sdk-1.2.6/ios/.gitignore
  18. 0
      umeng_common_sdk-1.2.6/ios/Assets/.gitkeep
  19. 4
      umeng_common_sdk-1.2.6/ios/Classes/UmengCommonSdkPlugin.h
  20. 102
      umeng_common_sdk-1.2.6/ios/Classes/UmengCommonSdkPlugin.m
  21. 26
      umeng_common_sdk-1.2.6/ios/umeng_common_sdk.podspec
  22. 57
      umeng_common_sdk-1.2.6/lib/umeng_common_sdk.dart
  23. 64
      umeng_common_sdk-1.2.6/pubspec.yaml
  24. 23
      umeng_common_sdk-1.2.6/test/umeng_common_sdk_test.dart

7
android/build.gradle

@ -17,6 +17,7 @@ buildscript {
} }
maven { url "https://www.jitpack.io" } maven { url "https://www.jitpack.io" }
maven {url 'https://developer.huawei.com/repo/'} maven {url 'https://developer.huawei.com/repo/'}
maven { url 'https://repo1.maven.org/maven2/' }
} }
dependencies { dependencies {
@ -25,6 +26,11 @@ buildscript {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.huawei.agconnect:agcp:1.4.1.300' classpath 'com.huawei.agconnect:agcp:1.4.1.300'
classpath 'com.mob.sdk:MobSDK:+' classpath 'com.mob.sdk:MobSDK:+'
classpath 'com.android.tools.build:gradle:3.4.0'
classpath fileTree(include:['*.jar'], dir:'libs')
classpath 'com.umeng.umsdk:common:9.4.7'
classpath 'com.umeng.umsdk:asms:1.4.0'
classpath 'com.umeng.umsdk:abtest:1.0.0'
} }
} }
@ -46,6 +52,7 @@ allprojects {
} }
maven { url "https://www.jitpack.io" } maven { url "https://www.jitpack.io" }
maven { url 'https://developer.huawei.com/repo/'} maven { url 'https://developer.huawei.com/repo/'}
maven { url 'https://repo1.maven.org/maven2/' }
} }
} }

37
lib/base_state.dart

@ -6,7 +6,6 @@ import 'package:shared_preferences/shared_preferences.dart';
abstract class BaseState<T extends StatefulWidget> extends State<T> abstract class BaseState<T extends StatefulWidget> extends State<T>
with WidgetsBindingObserver { with WidgetsBindingObserver {
int lastTime = DateTime.now().millisecondsSinceEpoch; int lastTime = DateTime.now().millisecondsSinceEpoch;
@override @override
@ -23,7 +22,7 @@ abstract class BaseState<T extends StatefulWidget> extends State<T>
break; break;
case AppLifecycleState.resumed: // case AppLifecycleState.resumed: //
pushRoute(); pushRoute();
if(DateTime.now().millisecondsSinceEpoch - lastTime > 300000) if (DateTime.now().millisecondsSinceEpoch - lastTime > 300000)
Navigator.of(context).popAndPushNamed('/router/main_page'); Navigator.of(context).popAndPushNamed('/router/main_page');
break; break;
case AppLifecycleState.paused: // case AppLifecycleState.paused: //
@ -56,40 +55,58 @@ abstract class BaseState<T extends StatefulWidget> extends State<T>
String routeName = ""; String routeName = "";
Map<String, dynamic> params = {}; Map<String, dynamic> params = {};
switch (pushMap["typed"].toString()) { switch (pushMap["typed"].toString()) {
case "1":case "ARTICLE": case "1":
case "ARTICLE":
routeName = "/router/web_page"; routeName = "/router/web_page";
params["articleId"] = pushMap["info"]; params["articleId"] = pushMap["info"];
break; break;
case "2":case "ACTIVITY": case "2":
case "ACTIVITY":
routeName = "/router/web_page"; routeName = "/router/web_page";
params["activityId"] = pushMap["info"]; params["activityId"] = pushMap["info"];
break; break;
case "3":case "SHOP": case "3":
case "SHOP":
routeName = "/router/store_order"; routeName = "/router/store_order";
params["id"] = pushMap["info"]; params["id"] = pushMap["info"];
params["tenant"] = pushMap["tenant"]; params["tenant"] = pushMap["tenant"];
params["storeName"] = pushMap["storeName"]; params["storeName"] = pushMap["storeName"];
break; break;
case "4":case "CREDIT_GOODS": case "4":
case "CREDIT_GOODS":
routeName = "/router/integral_store_page"; routeName = "/router/integral_store_page";
params["goodsId"] = pushMap["info"]; params["goodsId"] = pushMap["info"];
break; break;
case "5":case "ORDER": case "5":
case "ORDER":
routeName = "/router/order_details"; routeName = "/router/order_details";
params["id"] = pushMap["info"]; params["id"] = pushMap["info"];
break; break;
case "6":case "MEMBER": case "6":
case "MEMBER":
routeName = "/router/community_details"; routeName = "/router/community_details";
params["businessId"] = pushMap["info"]; params["businessId"] = pushMap["info"];
break; break;
case "8":case "WALLET": case "8":
case "WALLET":
routeName = "/router/mine_wallet"; routeName = "/router/mine_wallet";
params["id"] = pushMap["info"]; params["id"] = pushMap["info"];
break; break;
case "9":case "WELFARE": case "9":
case "WELFARE":
routeName = "/router/welfare_page"; routeName = "/router/welfare_page";
params["id"] = pushMap["info"]; params["id"] = pushMap["info"];
break; break;
case "12":
case "COUPON":
routeName = "/router/coupon_page";
params["id"] = pushMap["info"];
break;
case "13":
case "CATE_BEAN":
routeName = "/router/trading_card_page";
params["id"] = pushMap["info"];
break;
} }
sharedPreferences.setString("pushData", ""); sharedPreferences.setString("pushData", "");
print("xgPushClickAction: routeName: $routeName"); print("xgPushClickAction: routeName: $routeName");

33
lib/main_page.dart

@ -2,6 +2,7 @@ import 'dart:convert';
import 'dart:io'; import 'dart:io';
import 'package:dio/dio.dart'; import 'package:dio/dio.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_baidu_mapapi_base/flutter_baidu_mapapi_base.dart'; import 'package:flutter_baidu_mapapi_base/flutter_baidu_mapapi_base.dart';
import 'package:flutter_bmflocation/flutter_bmflocation.dart'; import 'package:flutter_bmflocation/flutter_bmflocation.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart'; import 'package:flutter_easyloading/flutter_easyloading.dart';
@ -33,6 +34,7 @@ import 'package:sharesdk_plugin/sharesdk_interface.dart';
import 'package:sharesdk_plugin/sharesdk_register.dart'; import 'package:sharesdk_plugin/sharesdk_register.dart';
import 'package:tpns_flutter_plugin/android/xg_android_api.dart'; import 'package:tpns_flutter_plugin/android/xg_android_api.dart';
import 'package:tpns_flutter_plugin/tpns_flutter_plugin.dart'; import 'package:tpns_flutter_plugin/tpns_flutter_plugin.dart';
import 'package:umeng_common_sdk/umeng_common_sdk.dart';
import 'community/order_page.dart'; import 'community/order_page.dart';
@ -59,6 +61,7 @@ class _MainPage extends State<MainPage> with WidgetsBindingObserver {
// List<String> iconn; // List<String> iconn;
ApiService apiService; ApiService apiService;
int lastTime = DateTime.now().millisecondsSinceEpoch; int lastTime = DateTime.now().millisecondsSinceEpoch;
String _platformVersion = 'Unknown';
@override @override
void dispose() { void dispose() {
@ -111,6 +114,9 @@ class _MainPage extends State<MainPage> with WidgetsBindingObserver {
..dismissOnTap = false; ..dismissOnTap = false;
initSdk(); initSdk();
UmengCommonSdk.initCommon('6491509087568a379b5a1345', '6491509087568a379b5a1345', 'Umeng');
UmengCommonSdk.setPageCollectionModeManual();
initPlatformState();
pushRoute(); pushRoute();
@ -187,6 +193,21 @@ class _MainPage extends State<MainPage> with WidgetsBindingObserver {
final XgFlutterPlugin xgFlutterPlugin = XgFlutterPlugin(); final XgFlutterPlugin xgFlutterPlugin = XgFlutterPlugin();
Future<void> initPlatformState() async {
String platformVersion;
try {
platformVersion = (await UmengCommonSdk.platformVersion);
} on PlatformException {
platformVersion = 'Failed to get platform version.';
}
if (!mounted) return;
setState(() {
_platformVersion = platformVersion;
});
}
initSdk() async { initSdk() async {
xgFlutterPlugin.stopXg(); xgFlutterPlugin.stopXg();
@ -247,7 +268,7 @@ class _MainPage extends State<MainPage> with WidgetsBindingObserver {
); );
} }
/// @typed: ARTICLE(1) ACTIVITY(2) SHOP(3) CREDIT_GOODS(4) ORDER(5) TREND(6) MEMBER(7) WALLET(8)/ WELFARE(9) /// @typed: ARTICLE(1) ACTIVITY(2) SHOP(3) CREDIT_GOODS(4) ORDER(5) TREND(6) MEMBER(7) WALLET(8)/ WELFARE(9) COUPON(12) CATE_BEAN(13)
xgFlutterPlugin.addEventHandler(xgPushClickAction: (event) async { xgFlutterPlugin.addEventHandler(xgPushClickAction: (event) async {
print("xgPushClickAction1: $event"); print("xgPushClickAction1: $event");
if (event["actionType"] == 2) return event; if (event["actionType"] == 2) return event;
@ -354,6 +375,16 @@ class _MainPage extends State<MainPage> with WidgetsBindingObserver {
routeName = "/router/welfare_page"; routeName = "/router/welfare_page";
params["id"] = pushMap["info"]; params["id"] = pushMap["info"];
break; break;
case "12":
case "COUPON":
routeName = "/router/coupon_page";
params["id"] = pushMap["info"];
break;
case "13":
case "CATE_BEAN":
routeName = "/router/trading_card_page";
params["id"] = pushMap["info"];
break;
} }
sharedPreferences.setString("pushData", ""); sharedPreferences.setString("pushData", "");
print("xgPushClickAction: routeName: $routeName"); print("xgPushClickAction: routeName: $routeName");

11
pubspec.lock

@ -321,7 +321,7 @@ packages:
name: fluwx name: fluwx
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "3.13.1" version: "3.9.0+2"
font_awesome_flutter: font_awesome_flutter:
dependency: "direct main" dependency: "direct main"
description: description:
@ -767,7 +767,7 @@ packages:
name: tobias name: tobias
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "2.4.2" version: "2.4.1"
tpns_flutter_plugin: tpns_flutter_plugin:
dependency: "direct main" dependency: "direct main"
description: description:
@ -798,6 +798,13 @@ packages:
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.3.2" version: "1.3.2"
umeng_common_sdk:
dependency: "direct main"
description:
name: umeng_common_sdk
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.2.6"
url_launcher: url_launcher:
dependency: "direct main" dependency: "direct main"
description: description:

5
pubspec.yaml

@ -3,7 +3,7 @@ description: 一心回乡.
publish_to: 'none' # Remove this line if you wish to publish to pub.dev publish_to: 'none' # Remove this line if you wish to publish to pub.dev
version: 3.2.14+58 version: 3.2.16+60
environment: environment:
sdk: ">=2.7.0 <3.0.0" sdk: ">=2.7.0 <3.0.0"
@ -27,6 +27,7 @@ dependencies:
url: https://github.com/TencentCloud/TPNS-Flutter-Plugin url: https://github.com/TencentCloud/TPNS-Flutter-Plugin
ref: V1.1.6 ref: V1.1.6
umeng_common_sdk: ^1.2.3
like_button: ^2.0.2 like_button: ^2.0.2
cupertino_icons: ^1.0.2 cupertino_icons: ^1.0.2
flutter_swiper: ^1.1.6 flutter_swiper: ^1.1.6
@ -143,3 +144,5 @@ flutter:
flutter_intl: flutter_intl:
enabled: true enabled: true
umeng_common_sdk:path: umeng_common_sdk-1.2.6

15
umeng_common_sdk-1.2.6/.gitignore vendored

@ -0,0 +1,15 @@
.DS_Store
.dart_tool/
.packages
.pub/
example/.flutter-plugins-dependencies
example/ios/Flutter/flutter_export_environment.sh
**/pubspec.lock
build/
.idea/
**/.idea/
**/gradle/
**/gradlew
**/gradlew.bat

10
umeng_common_sdk-1.2.6/.metadata

@ -0,0 +1,10 @@
# This file tracks properties of this Flutter project.
# Used by Flutter tool to assess capabilities and perform upgrades etc.
#
# This file should be version controlled and should not be manually edited.
version:
revision: 9b2d32b605630f28625709ebd9d78ab3016b2bf6
channel: stable
project_type: plugin

43
umeng_common_sdk-1.2.6/CHANGELOG.md

@ -0,0 +1,43 @@
##1.2.6
-Android端plugin插件项目依赖的common包版本升级到9.5.6,asms包版本升级到1.6.3。
-Android端example工程增加MyApp类文件,将UMConfigure.preInit函数放到MyApp类中io.flutter.app.FlutterApplication
.onCreate生命周期函数中执行。
##1.2.5
-Android 稳定性优化;
##1.2.4
-Android 上下文获取优化;
##1.2.3
-Android 依赖库asms更新1.4.1;
##1.2.2
-Android 依赖更新;初始化简化;
##1.2.1
-Android Example工程初始化优化;
##1.2.0
-支持空安全;
##1.1.3
-Android Example工程优化;Android依赖库迁移maven center;
##1.1.2
-Android Example工程添加release包混淆规则
##1.1.1
-Android依赖库改为线上maven形式
##1.1.0
-优化描述,同步友盟+官方下载flutter插件
## 0.0.3
-example工程完善基础组件初始化
## 0.0.2
-同步最新友盟+common库
## 0.0.1
-初始提交

1
umeng_common_sdk-1.2.6/LICENSE

@ -0,0 +1 @@
Add your license here.

14
umeng_common_sdk-1.2.6/README.md

@ -0,0 +1,14 @@
# umeng_common_sdk Flutter Plugin
# 安装
在工程 pubspec.yaml 中加入 dependencies
dependencies:
umeng_common_sdk: 1.2.6
# 使用
import 'package:umeng_common_sdk/umeng_common_sdk.dart';
**注意** : 需要先调用 UMConfigure.init 来初始化插件(Appkey可在统计后台 “管理->应用管理->应用列表” 页面查看,或在 “我的产品”选择某应用->设置->应用信息 查看Appkey),才能保证其他功能正常工作。

8
umeng_common_sdk-1.2.6/android/.gitignore vendored

@ -0,0 +1,8 @@
*.iml
.gradle
/local.properties
/.idea/workspace.xml
/.idea/libraries
.DS_Store
/build
/captures

40
umeng_common_sdk-1.2.6/android/build.gradle

@ -0,0 +1,40 @@
group 'com.umeng.umeng_common_sdk'
version '1.0'
buildscript {
repositories {
google()
jcenter()
maven { url 'https://repo1.maven.org/maven2/'}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.0'
}
}
rootProject.allprojects {
repositories {
google()
jcenter()
maven { url 'https://repo1.maven.org/maven2/'}
}
}
apply plugin: 'com.android.library'
android {
compileSdkVersion 29
defaultConfig {
minSdkVersion 16
}
lintOptions {
disable 'InvalidPackage'
}
}
dependencies {
api 'com.umeng.umsdk:common:9.5.6'//
api 'com.umeng.umsdk:asms:1.6.3'//
}

3
umeng_common_sdk-1.2.6/android/gradle.properties

@ -0,0 +1,3 @@
org.gradle.jvmargs=-Xmx1536M
android.useAndroidX=true
android.enableJetifier=true

1
umeng_common_sdk-1.2.6/android/settings.gradle

@ -0,0 +1 @@
rootProject.name = 'umeng_common_sdk'

3
umeng_common_sdk-1.2.6/android/src/main/AndroidManifest.xml

@ -0,0 +1,3 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.umeng.umeng_common_sdk">
</manifest>

214
umeng_common_sdk-1.2.6/android/src/main/java/com/umeng/umeng_common_sdk/UmengCommonSdkPlugin.java

@ -0,0 +1,214 @@
package com.umeng.umeng_common_sdk;
import android.content.Context;
import androidx.annotation.NonNull;
import com.umeng.analytics.MobclickAgent;
import com.umeng.commonsdk.UMConfigure;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.List;
import java.util.Map;
import io.flutter.embedding.engine.plugins.FlutterPlugin;
import io.flutter.plugin.common.MethodCall;
import io.flutter.plugin.common.MethodChannel;
import io.flutter.plugin.common.MethodChannel.MethodCallHandler;
import io.flutter.plugin.common.MethodChannel.Result;
import io.flutter.plugin.common.PluginRegistry.Registrar;
/** UmengCommonSdkPlugin */
public class UmengCommonSdkPlugin implements FlutterPlugin, MethodCallHandler {
/// The MethodChannel that will the communication between Flutter and native Android
///
/// This local reference serves to register the plugin with the Flutter Engine and unregister it
/// when the Flutter Engine is detached from the Activity
private MethodChannel channel;
public static void registerWith(Registrar registrar) {
final MethodChannel channel = new MethodChannel(registrar.messenger(), "umeng_common_sdk");
UmengCommonSdkPlugin plugin = new UmengCommonSdkPlugin();
plugin.mContext = registrar.context();
channel.setMethodCallHandler(plugin);
onAttachedEngineAdd();
}
private static void onAttachedEngineAdd() {
// add by umeng
try {
Class<?> agent = Class.forName("com.umeng.analytics.MobclickAgent");
Method[] methods = agent.getDeclaredMethods();
for (Method m : methods) {
android.util.Log.e("UMLog", "Reflect:"+m);
if(m.getName().equals("onEventObject")) {
versionMatch = true;
break;
}
}
if(!versionMatch) {
android.util.Log.e("UMLog", "安卓SDK版本过低,建议升级至8以上");
//return;
}
else {
android.util.Log.e("UMLog", "安卓依赖版本检查成功");
}
}
catch (Exception e) {
e.printStackTrace();
android.util.Log.e("UMLog", "SDK版本过低,请升级至8以上"+e.toString());
return;
}
Method method = null;
try {
Class<?> config = Class.forName("com.umeng.commonsdk.UMConfigure");
method = config.getDeclaredMethod("setWraperType", String.class, String.class);
method.setAccessible(true);
method.invoke(null, "flutter","1.0");
android.util.Log.i("UMLog", "setWraperType:flutter1.0 success");
}
catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException | ClassNotFoundException e) {
e.printStackTrace();
android.util.Log.e("UMLog", "setWraperType:flutter1.0"+e.toString());
}
}
@Override
public void onAttachedToEngine(@NonNull FlutterPluginBinding flutterPluginBinding) {
mContext = flutterPluginBinding.getApplicationContext();
channel = new MethodChannel(flutterPluginBinding.getBinaryMessenger(), "umeng_common_sdk");
channel.setMethodCallHandler(this);
onAttachedEngineAdd();
}
private static Context mContext = null;
@Override
public void onMethodCall(@NonNull MethodCall call, @NonNull Result result) {
if(!versionMatch) {
android.util.Log.e("UMLog", "onMethodCall:"+call.method+":安卓SDK版本过低,请升级至8以上");
//return;
}
try {
List args = (List) call.arguments;
switch (call.method) {
case "getPlatformVersion":
result.success("Android " + android.os.Build.VERSION.RELEASE);
break;
case "initCommon":
initCommon(args);
break;
case "onEvent":
onEvent(args);
break;
case "onProfileSignIn":
onProfileSignIn(args);
break;
case "onProfileSignOff":
onProfileSignOff();
break;
case "setPageCollectionModeAuto":
setPageCollectionModeAuto();
break;
case "setPageCollectionModeManual":
setPageCollectionModeManual();
break;
case "onPageStart":
onPageStart(args);
break;
case "onPageEnd":
onPageEnd(args);
break;
case "reportError":
reportError(args);
break;
default:
result.notImplemented();
break;
}
} catch (Exception e) {
e.printStackTrace();
android.util.Log.e("Umeng", "Exception:"+e.getMessage());
}
}
@Override
public void onDetachedFromEngine(@NonNull FlutterPluginBinding binding) {
channel.setMethodCallHandler(null);
}
private static Boolean versionMatch = false;
public static void setContext (Context ctx) {
mContext = ctx;
}
public static Context getContext () {
return mContext;
}
private void initCommon(List args) {
String appkey = (String)args.get(0);
String channel = (String)args.get(2);
UMConfigure.init(getContext(), appkey, channel, UMConfigure.DEVICE_TYPE_PHONE, null);
android.util.Log.i("UMLog", "initCommon:"+appkey+"@"+channel);
}
private void onEvent(List args) {
String event = (String)args.get(0);
Map map = null ;
if(args.size()>1) {
map = (Map) args.get(1);
}
//JSONObject properties = new JSONObject(map);
MobclickAgent.onEventObject(getContext(), event, map);
if(map!=null) {
// android.util.Log.i("UMLog", "onEventObject:"+event+"("+map.toString()+")");
}
else {
// android.util.Log.i("UMLog", "onEventObject:"+event);
}
}
private void onProfileSignIn (List args) {
String userID = (String)args.get(0);
MobclickAgent.onProfileSignIn(userID);
android.util.Log.i("UMLog", "onProfileSignIn:"+userID);
}
private void onProfileSignOff () {
MobclickAgent.onProfileSignOff();
android.util.Log.i("UMLog", "onProfileSignOff");
}
private void setPageCollectionModeAuto () {
MobclickAgent.setPageCollectionMode(MobclickAgent.PageMode.AUTO);
android.util.Log.i("UMLog", "setPageCollectionModeAuto");
}
private void setPageCollectionModeManual () {
MobclickAgent.setPageCollectionMode(MobclickAgent.PageMode.MANUAL);
android.util.Log.i("UMLog", "setPageCollectionModeManual");
}
private void onPageStart(List args) {
String event = (String)args.get(0);
MobclickAgent.onPageStart(event);
android.util.Log.i("UMLog", "onPageStart:"+event);
}
private void onPageEnd(List args) {
String event = (String)args.get(0);
MobclickAgent.onPageEnd(event);
android.util.Log.i("UMLog", "onPageEnd:"+event);
}
private void reportError(List args){
String error = (String)args.get(0);
MobclickAgent.reportError(getContext(), error);
android.util.Log.i("UMLog", "reportError:"+error);
}
}

37
umeng_common_sdk-1.2.6/ios/.gitignore vendored

@ -0,0 +1,37 @@
.idea/
.vagrant/
.sconsign.dblite
.svn/
.DS_Store
*.swp
profile
DerivedData/
build/
GeneratedPluginRegistrant.h
GeneratedPluginRegistrant.m
.generated/
*.pbxuser
*.mode1v3
*.mode2v3
*.perspectivev3
!default.pbxuser
!default.mode1v3
!default.mode2v3
!default.perspectivev3
xcuserdata
*.moved-aside
*.pyc
*sync/
Icon?
.tags*
/Flutter/Generated.xcconfig
/Flutter/flutter_export_environment.sh

0
umeng_common_sdk-1.2.6/ios/Assets/.gitkeep

4
umeng_common_sdk-1.2.6/ios/Classes/UmengCommonSdkPlugin.h

@ -0,0 +1,4 @@
#import <Flutter/Flutter.h>
@interface UmengCommonSdkPlugin : NSObject<FlutterPlugin>
@end

102
umeng_common_sdk-1.2.6/ios/Classes/UmengCommonSdkPlugin.m

@ -0,0 +1,102 @@
#import "UmengCommonSdkPlugin.h"
#import <UMCommon/UMConfigure.h>
#import <UMCommon/MobClick.h>
@interface UMengflutterpluginForUMCommon : NSObject
@end
@implementation UMengflutterpluginForUMCommon
+ (BOOL)handleMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result{
BOOL resultCode = YES;
if ([@"initCommon" isEqualToString:call.method]){
NSArray* arguments = (NSArray *)call.arguments;
NSString* appkey = arguments[1];
NSString* channel = arguments[2];
[UMConfigure initWithAppkey:appkey channel:channel];
//result(@"success");
}
else{
resultCode = NO;
}
return resultCode;
}
@end
@interface UMengflutterpluginForAnalytics : NSObject
@end
@implementation UMengflutterpluginForAnalytics : NSObject
+ (BOOL)handleMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result{
BOOL resultCode = YES;
NSArray* arguments = (NSArray *)call.arguments;
if ([@"onEvent" isEqualToString:call.method]){
NSString* eventName = arguments[0];
NSDictionary* properties = arguments[1];
[MobClick event:eventName attributes:properties];
//result(@"success");
}
else if ([@"onProfileSignIn" isEqualToString:call.method]){
NSString* userID = arguments[0];
[MobClick profileSignInWithPUID:userID];
//result(@"success");
}
else if ([@"onProfileSignOff" isEqualToString:call.method]){
[MobClick profileSignOff];
//result(@"success");
}
else if ([@"setPageCollectionModeAuto" isEqualToString:call.method]){
[MobClick setAutoPageEnabled:YES];
//result(@"success");
}
else if ([@"setPageCollectionModeManual" isEqualToString:call.method]){
[MobClick setAutoPageEnabled:NO];
//result(@"success");
}
else if ([@"onPageStart" isEqualToString:call.method]){
NSString* pageName = arguments[0];
[MobClick beginLogPageView:pageName];
//result(@"success");
}
else if ([@"onPageEnd" isEqualToString:call.method]){
NSString* pageName = arguments[0];
[MobClick endLogPageView:pageName];
//result(@"success");
}
else if ([@"reportError" isEqualToString:call.method]){
NSLog(@"reportError API not existed ");
//result(@"success");
}
else{
resultCode = NO;
}
return resultCode;
}
@end
@implementation UmengCommonSdkPlugin
+ (void)registerWithRegistrar:(NSObject<FlutterPluginRegistrar>*)registrar {
FlutterMethodChannel* channel = [FlutterMethodChannel
methodChannelWithName:@"umeng_common_sdk"
binaryMessenger:[registrar messenger]];
UmengCommonSdkPlugin* instance = [[UmengCommonSdkPlugin alloc] init];
[registrar addMethodCallDelegate:instance channel:channel];
}
- (void)handleMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result {
if ([@"getPlatformVersion" isEqualToString:call.method]) {
result([@"iOS " stringByAppendingString:[[UIDevice currentDevice] systemVersion]]);
} else {
//result(FlutterMethodNotImplemented);
}
BOOL resultCode = [UMengflutterpluginForUMCommon handleMethodCall:call result:result];
if (resultCode) return;
resultCode = [UMengflutterpluginForAnalytics handleMethodCall:call result:result];
if (resultCode) return;
result(FlutterMethodNotImplemented);
}
@end

26
umeng_common_sdk-1.2.6/ios/umeng_common_sdk.podspec

@ -0,0 +1,26 @@
#
# To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html.
# Run `pod lib lint umeng_common_sdk.podspec' to validate before publishing.
#
Pod::Spec.new do |s|
s.name = 'umeng_common_sdk'
s.version = '0.0.1'
s.summary = 'A new Flutter plugin.'
s.description = <<-DESC
A new Flutter plugin.
DESC
s.homepage = 'http://example.com'
s.license = { :file => '../LICENSE' }
s.author = { 'Your Company' => 'email@example.com' }
s.source = { :path => '.' }
s.source_files = 'Classes/**/*'
s.public_header_files = 'Classes/**/*.h'
s.dependency 'Flutter'
s.platform = :ios, '8.0'
s.dependency 'UMCommon'
s.dependency 'UMDevice'
s.static_framework = true
# Flutter.framework does not contain a i386 slice. Only x86_64 simulators are supported.
s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES', 'VALID_ARCHS[sdk=iphonesimulator*]' => 'x86_64' }
end

57
umeng_common_sdk-1.2.6/lib/umeng_common_sdk.dart

@ -0,0 +1,57 @@
import 'dart:async';
import 'package:flutter/services.dart';
class UmengCommonSdk {
static const MethodChannel _channel =
const MethodChannel('umeng_common_sdk');
static Future<String> get platformVersion async {
final String version = await _channel.invokeMethod('getPlatformVersion');
return version;
}
static Future<dynamic> initCommon(String androidAppkey, String iosAppkey, String channel) async {
List<dynamic> params = [androidAppkey, iosAppkey ,channel];
final dynamic result = await _channel.invokeMethod('initCommon', params);
return result;
}
static void onEvent(String event, Map<String,dynamic> properties) {
List<dynamic> args = [event,properties];
_channel.invokeMethod('onEvent', args);
}
static void onProfileSignIn (String userID) {
List<dynamic> args = [userID];
_channel.invokeMethod('onProfileSignIn', args);
}
static void onProfileSignOff () {
_channel.invokeMethod('onProfileSignOff');
}
static void setPageCollectionModeManual() {
_channel.invokeMethod('setPageCollectionModeManual');
}
static void onPageStart(String viewName) {
List<dynamic> args = [viewName];
_channel.invokeMethod('onPageStart', args);
}
static void onPageEnd(String viewName) {
List<dynamic> args = [viewName];
_channel.invokeMethod('onPageEnd', args);
}
static void setPageCollectionModeAuto() {
_channel.invokeMethod('setPageCollectionModeAuto');
}
static void reportError(String error) {
List<dynamic> args = [error];
_channel.invokeMethod('reportError', args);
}
}

64
umeng_common_sdk-1.2.6/pubspec.yaml

@ -0,0 +1,64 @@
name: umeng_common_sdk
description: 友盟+组件化基础库:Common Flutter plugin(Android & iOS).
version: 1.2.6
homepage: https://www.umeng.com
environment:
sdk: '>=2.12.0 <3.0.0'
flutter: ">=1.10.0"
dependencies:
flutter:
sdk: flutter
dev_dependencies:
flutter_test:
sdk: flutter
# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec
# The following section is specific to Flutter.
flutter:
# This section identifies this Flutter project as a plugin project.
# The 'pluginClass' and Android 'package' identifiers should not ordinarily
# be modified. They are used by the tooling to maintain consistency when
# adding or updating assets for this project.
plugin:
platforms:
android:
package: com.umeng.umeng_common_sdk
pluginClass: UmengCommonSdkPlugin
ios:
pluginClass: UmengCommonSdkPlugin
# To add assets to your plugin package, add an assets section, like this:
# assets:
# - images/a_dot_burr.jpeg
# - images/a_dot_ham.jpeg
#
# For details regarding assets in packages, see
# https://flutter.dev/assets-and-images/#from-packages
#
# An image asset can refer to one or more resolution-specific "variants", see
# https://flutter.dev/assets-and-images/#resolution-aware.
# To add custom fonts to your plugin package, add a fonts section here,
# in this "flutter" section. Each entry in this list should have a
# "family" key with the font family name, and a "fonts" key with a
# list giving the asset and other descriptors for the font. For
# example:
# fonts:
# - family: Schyler
# fonts:
# - asset: fonts/Schyler-Regular.ttf
# - asset: fonts/Schyler-Italic.ttf
# style: italic
# - family: Trajan Pro
# fonts:
# - asset: fonts/TrajanPro.ttf
# - asset: fonts/TrajanPro_Bold.ttf
# weight: 700
#
# For details regarding fonts in packages, see
# https://flutter.dev/custom-fonts/#from-packages

23
umeng_common_sdk-1.2.6/test/umeng_common_sdk_test.dart

@ -0,0 +1,23 @@
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:umeng_common_sdk/umeng_common_sdk.dart';
void main() {
const MethodChannel channel = MethodChannel('umeng_common_sdk');
TestWidgetsFlutterBinding.ensureInitialized();
setUp(() {
channel.setMockMethodCallHandler((MethodCall methodCall) async {
return '42';
});
});
tearDown(() {
channel.setMockMethodCallHandler(null);
});
test('getPlatformVersion', () async {
expect(await UmengCommonSdk.platformVersion, '42');
});
}
Loading…
Cancel
Save