wurong
2 years ago
24 changed files with 770 additions and 40 deletions
@ -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 |
@ -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 |
@ -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 |
||||||
|
-初始提交 |
@ -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),才能保证其他功能正常工作。 |
@ -0,0 +1,8 @@ |
|||||||
|
*.iml |
||||||
|
.gradle |
||||||
|
/local.properties |
||||||
|
/.idea/workspace.xml |
||||||
|
/.idea/libraries |
||||||
|
.DS_Store |
||||||
|
/build |
||||||
|
/captures |
@ -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'// 必选 |
||||||
|
} |
@ -0,0 +1,3 @@ |
|||||||
|
org.gradle.jvmargs=-Xmx1536M |
||||||
|
android.useAndroidX=true |
||||||
|
android.enableJetifier=true |
@ -0,0 +1 @@ |
|||||||
|
rootProject.name = 'umeng_common_sdk' |
@ -0,0 +1,3 @@ |
|||||||
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android" |
||||||
|
package="com.umeng.umeng_common_sdk"> |
||||||
|
</manifest> |
@ -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); |
||||||
|
} |
||||||
|
} |
@ -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,0 +1,4 @@ |
|||||||
|
#import <Flutter/Flutter.h> |
||||||
|
|
||||||
|
@interface UmengCommonSdkPlugin : NSObject<FlutterPlugin> |
||||||
|
@end |
@ -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 |
@ -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 |
@ -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); |
||||||
|
} |
||||||
|
} |
@ -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 |
@ -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…
Reference in new issue