├── .gitignore ├── .metadata ├── CHANGELOG.md ├── LICENSE ├── README.md ├── android ├── .gitignore ├── build.gradle ├── gradle.properties ├── libs │ ├── arm64-v8a │ │ ├── libcocklogic-1.1.3.so │ │ └── libtnet-3.1.14.so │ ├── armeabi-v7a │ │ ├── libcocklogic-1.1.3.so │ │ └── libtnet-3.1.14.so │ ├── armeabi │ │ ├── libcocklogic-1.1.3.so │ │ └── libtnet-3.1.14.so │ ├── mips │ │ ├── libcocklogic-1.1.3.so │ │ └── libtnet-3.1.14.so │ ├── mips64 │ │ └── libtnet-3.1.14.so │ └── x86 │ │ ├── libcocklogic-1.1.3.so │ │ └── libtnet-3.1.14.so ├── settings.gradle └── src │ └── main │ ├── AndroidManifest.xml │ └── java │ └── com │ └── studyyoun │ └── flutter_fai_umeng │ ├── FlutterFaiUmengPlugin.java │ ├── MeizuReceiver.java │ ├── MessageChannelItem.java │ ├── MiPushActivity.java │ ├── MyPushIntentService.java │ └── UmengUtils.java ├── example ├── .gitignore ├── .metadata ├── README.md ├── android │ ├── app │ │ ├── build.gradle │ │ └── src │ │ │ ├── debug │ │ │ └── AndroidManifest.xml │ │ │ ├── main │ │ │ ├── AndroidManifest.xml │ │ │ ├── java │ │ │ │ └── com │ │ │ │ │ └── studyyoun │ │ │ │ │ └── flutter_fai_umeng_example │ │ │ │ │ └── MainActivity.java │ │ │ └── res │ │ │ │ ├── drawable │ │ │ │ └── launch_background.xml │ │ │ │ ├── mipmap-hdpi │ │ │ │ └── ic_launcher.png │ │ │ │ ├── mipmap-mdpi │ │ │ │ └── ic_launcher.png │ │ │ │ ├── mipmap-xhdpi │ │ │ │ └── ic_launcher.png │ │ │ │ ├── mipmap-xxhdpi │ │ │ │ └── ic_launcher.png │ │ │ │ ├── mipmap-xxxhdpi │ │ │ │ └── ic_launcher.png │ │ │ │ ├── values │ │ │ │ └── styles.xml │ │ │ │ └── xml │ │ │ │ └── network_security_config.xml │ │ │ └── profile │ │ │ └── AndroidManifest.xml │ ├── build.gradle │ ├── gradle.properties │ └── settings.gradle ├── ios │ ├── Flutter │ │ ├── AppFrameworkInfo.plist │ │ ├── Debug.xcconfig │ │ ├── Release.xcconfig │ │ └── flutter_export_environment.sh │ ├── Podfile │ ├── Runner.xcodeproj │ │ ├── project.pbxproj │ │ ├── project.xcworkspace │ │ │ └── contents.xcworkspacedata │ │ └── xcshareddata │ │ │ └── xcschemes │ │ │ └── Runner.xcscheme │ ├── Runner.xcworkspace │ │ └── contents.xcworkspacedata │ └── Runner │ │ ├── AppDelegate.h │ │ ├── AppDelegate.m │ │ ├── Assets.xcassets │ │ ├── AppIcon.appiconset │ │ │ ├── Contents.json │ │ │ ├── Icon-App-1024x1024@1x.png │ │ │ ├── Icon-App-20x20@1x.png │ │ │ ├── Icon-App-20x20@2x.png │ │ │ ├── Icon-App-20x20@3x.png │ │ │ ├── Icon-App-29x29@1x.png │ │ │ ├── Icon-App-29x29@2x.png │ │ │ ├── Icon-App-29x29@3x.png │ │ │ ├── Icon-App-40x40@1x.png │ │ │ ├── Icon-App-40x40@2x.png │ │ │ ├── Icon-App-40x40@3x.png │ │ │ ├── Icon-App-60x60@2x.png │ │ │ ├── Icon-App-60x60@3x.png │ │ │ ├── Icon-App-76x76@1x.png │ │ │ ├── Icon-App-76x76@2x.png │ │ │ └── Icon-App-83.5x83.5@2x.png │ │ └── LaunchImage.imageset │ │ │ ├── Contents.json │ │ │ ├── LaunchImage.png │ │ │ ├── LaunchImage@2x.png │ │ │ ├── LaunchImage@3x.png │ │ │ └── README.md │ │ ├── Base.lproj │ │ ├── LaunchScreen.storyboard │ │ └── Main.storyboard │ │ ├── Info.plist │ │ ├── Runner.entitlements │ │ └── main.m ├── lib │ └── main.dart ├── pubspec.lock ├── pubspec.yaml └── test │ └── widget_test.dart ├── flutter_fai_umeng.iml ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── ios ├── .gitignore ├── Assets │ └── .gitkeep ├── Classes │ ├── FlutterFaiUmengPlugin.h │ ├── FlutterFaiUmengPlugin.m │ ├── UMengRecordTool.h │ └── UMengRecordTool.m └── flutter_fai_umeng.podspec ├── lib ├── flutter_fai_umeng.dart └── src │ └── native_umen.dart ├── pubspec.lock ├── pubspec.yaml ├── temp.md └── test └── flutter_fai_umeng_test.dart /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | .dart_tool/ 3 | 4 | .packages 5 | .pub/ 6 | 7 | build/ 8 | -------------------------------------------------------------------------------- /.metadata: -------------------------------------------------------------------------------- 1 | # This file tracks properties of this Flutter project. 2 | # Used by Flutter tool to assess capabilities and perform upgrades etc. 3 | # 4 | # This file should be version controlled and should not be manually edited. 5 | 6 | version: 7 | revision: d3eee57c0bd2e19aaa944be07b24c533075fd1a0 8 | channel: dev 9 | 10 | project_type: plugin 11 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | ## 0.0.2 4 | * 友盟推送功能 5 | 6 | ## 0.0.1 7 | 8 | * 友盟统计功能 9 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | BSD 2-Clause License 2 | 3 | Copyright(c)2020,早起的年轻人 4 | All rights reserved. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # flutter_fai_umeng 2 | 3 | 友盟统计 flutter 插件 4 | 5 | ## Getting Started 6 | 7 | 友盟统计插件 8 | 9 | ## 初始化 10 | 11 | ``` 12 | ///友盟的初始化 13 | ///参数一 appkey 14 | ///参数二 推送使用的pushSecret 15 | ///参数三 是否打开调试日志 16 | FlutterFaiUmeng.uMengInit("5dcfb8f84ca357f70e000b0a", 17 | pushSecret: "5cb4fc014c143a77fb85cb17edd807a2", logEnabled: true); 18 | 19 | /// 监听原生消息 20 | FlutterFaiUmeng.receiveMessage((message) { 21 | print(message); 22 | setState(() { 23 | _result = message.toString(); 24 | }); 25 | }); 26 | ``` -------------------------------------------------------------------------------- /android/.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/workspace.xml 5 | /.idea/libraries 6 | .DS_Store 7 | /build 8 | /captures 9 | -------------------------------------------------------------------------------- /android/build.gradle: -------------------------------------------------------------------------------- 1 | group 'com.studyyoun.flutter_fai_umeng' 2 | version '0.0.2' 3 | 4 | buildscript { 5 | repositories { 6 | google() 7 | jcenter() 8 | mavenCentral() 9 | maven { url 'https://dl.bintray.com/umsdk/release' } 10 | } 11 | 12 | dependencies { 13 | classpath 'com.android.tools.build:gradle:3.5.2' 14 | } 15 | } 16 | 17 | rootProject.allprojects { 18 | repositories { 19 | google() 20 | jcenter() 21 | mavenCentral() 22 | maven { url 'https://dl.bintray.com/umsdk/release' } 23 | } 24 | } 25 | 26 | apply plugin: 'com.android.library' 27 | 28 | android { 29 | compileSdkVersion 28 30 | 31 | defaultConfig { 32 | minSdkVersion 16 33 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" 34 | } 35 | lintOptions { 36 | disable 'InvalidPackage' 37 | } 38 | 39 | 40 | sourceSets { 41 | main { 42 | jniLibs.srcDirs = ['libs'] 43 | } 44 | } 45 | 46 | dependencies{ 47 | 48 | implementation fileTree(dir: 'libs', include: ['*.jar']) 49 | implementation 'androidx.appcompat:appcompat:1.1.0' 50 | implementation 'androidx.constraintlayout:constraintlayout:1.1.3' 51 | testImplementation 'junit:junit:4.12' 52 | androidTestImplementation 'androidx.test:runner:1.2.0' 53 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' 54 | // implementation 'com.umeng.umsdk:analytics:8.0.0' 55 | 56 | implementation 'com.umeng.umsdk:huawei-basetb:2.6.3.306' 57 | implementation 'com.umeng.umsdk:huawei-pushtb:2.6.3.306' 58 | implementation 'com.umeng.umsdk:huawei-umengaccs:1.2.4' 59 | 60 | implementation 'com.umeng.umsdk:meizu-push:3.8.7' 61 | implementation 'com.umeng.umsdk:meizu-umengaccs:1.1.1' 62 | 63 | implementation 'com.umeng.umsdk:oppo-push:2.0.2' 64 | implementation 'com.umeng.umsdk:oppo-umengaccs:1.0.6' 65 | 66 | implementation 'com.umeng.umsdk:vivo-push:2.3.5' 67 | implementation 'com.umeng.umsdk:vivo-umengaccs:1.1.0' 68 | 69 | implementation 'com.umeng.umsdk:xiaomi-push:3.7.0' 70 | implementation 'com.umeng.umsdk:xiaomi-umengaccs:1.1.4' 71 | 72 | //基础组件库依赖(必须) 73 | implementation 'com.umeng.umsdk:common:9.1.0' 74 | implementation 'com.umeng.umsdk:utdid:1.5.2' 75 | 76 | //友盟push相关依赖(必须) 77 | implementation 'com.umeng.umsdk:push:6.1.0' 78 | 79 | implementation 'com.umeng.umsdk:alicloud-httpdns:1.2.5' 80 | implementation 'com.umeng.umsdk:alicloud-utils:1.1.5' 81 | implementation 'com.umeng.umsdk:alicloud_beacon:1.0.1' 82 | 83 | implementation 'com.umeng.umsdk:agoo-accs:3.3.8.8-open-fix2' 84 | implementation 'com.umeng.umsdk:agoo_networksdk:3.5.5' 85 | implementation 'com.umeng.umsdk:agoo_tlog:3.0.0.17' 86 | implementation 'com.umeng.umsdk:agoo_tnet4android:3.1.14.9' 87 | 88 | implementation 'com.umeng.umsdk:asms:1.1.3' 89 | implementation 'com.umeng.umsdk:crash:0.0.4' 90 | 91 | 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /android/gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.jvmargs=-Xmx1536M 2 | 3 | android.useAndroidX=true 4 | android.enableJetifier=true 5 | -------------------------------------------------------------------------------- /android/libs/arm64-v8a/libcocklogic-1.1.3.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhaolongs/flutter_fai_umeng/ccfea9037741246c7cc442000a17926779675df8/android/libs/arm64-v8a/libcocklogic-1.1.3.so -------------------------------------------------------------------------------- /android/libs/arm64-v8a/libtnet-3.1.14.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhaolongs/flutter_fai_umeng/ccfea9037741246c7cc442000a17926779675df8/android/libs/arm64-v8a/libtnet-3.1.14.so -------------------------------------------------------------------------------- /android/libs/armeabi-v7a/libcocklogic-1.1.3.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhaolongs/flutter_fai_umeng/ccfea9037741246c7cc442000a17926779675df8/android/libs/armeabi-v7a/libcocklogic-1.1.3.so -------------------------------------------------------------------------------- /android/libs/armeabi-v7a/libtnet-3.1.14.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhaolongs/flutter_fai_umeng/ccfea9037741246c7cc442000a17926779675df8/android/libs/armeabi-v7a/libtnet-3.1.14.so -------------------------------------------------------------------------------- /android/libs/armeabi/libcocklogic-1.1.3.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhaolongs/flutter_fai_umeng/ccfea9037741246c7cc442000a17926779675df8/android/libs/armeabi/libcocklogic-1.1.3.so -------------------------------------------------------------------------------- /android/libs/armeabi/libtnet-3.1.14.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhaolongs/flutter_fai_umeng/ccfea9037741246c7cc442000a17926779675df8/android/libs/armeabi/libtnet-3.1.14.so -------------------------------------------------------------------------------- /android/libs/mips/libcocklogic-1.1.3.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhaolongs/flutter_fai_umeng/ccfea9037741246c7cc442000a17926779675df8/android/libs/mips/libcocklogic-1.1.3.so -------------------------------------------------------------------------------- /android/libs/mips/libtnet-3.1.14.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhaolongs/flutter_fai_umeng/ccfea9037741246c7cc442000a17926779675df8/android/libs/mips/libtnet-3.1.14.so -------------------------------------------------------------------------------- /android/libs/mips64/libtnet-3.1.14.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhaolongs/flutter_fai_umeng/ccfea9037741246c7cc442000a17926779675df8/android/libs/mips64/libtnet-3.1.14.so -------------------------------------------------------------------------------- /android/libs/x86/libcocklogic-1.1.3.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhaolongs/flutter_fai_umeng/ccfea9037741246c7cc442000a17926779675df8/android/libs/x86/libcocklogic-1.1.3.so -------------------------------------------------------------------------------- /android/libs/x86/libtnet-3.1.14.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhaolongs/flutter_fai_umeng/ccfea9037741246c7cc442000a17926779675df8/android/libs/x86/libtnet-3.1.14.so -------------------------------------------------------------------------------- /android/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'flutter_fai_umeng' 2 | -------------------------------------------------------------------------------- /android/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 28 | 29 | 30 | 31 | 32 | 33 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 66 | 67 | 70 | 71 | 74 | 75 | 76 | 77 | 78 | 79 | 83 | 84 | 85 | 86 | 87 | 88 | 92 | 93 | 94 | 95 | 96 | 97 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 114 | 115 | 116 | 117 | 118 | 119 | 122 | 123 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 148 | 149 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 182 | 185 | 186 | 187 | 188 | 191 | 192 | 193 | 194 | -------------------------------------------------------------------------------- /android/src/main/java/com/studyyoun/flutter_fai_umeng/FlutterFaiUmengPlugin.java: -------------------------------------------------------------------------------- 1 | package com.studyyoun.flutter_fai_umeng; 2 | 3 | import android.app.Notification; 4 | import android.content.BroadcastReceiver; 5 | import android.content.Context; 6 | import android.content.Intent; 7 | import android.os.Handler; 8 | import android.os.Looper; 9 | import android.util.Log; 10 | import android.widget.RemoteViews; 11 | import android.widget.Toast; 12 | 13 | import androidx.annotation.NonNull; 14 | 15 | import com.umeng.commonsdk.UMConfigure; 16 | import com.umeng.message.IUmengCallback; 17 | import com.umeng.message.IUmengRegisterCallback; 18 | import com.umeng.message.MsgConstant; 19 | import com.umeng.message.PushAgent; 20 | import com.umeng.message.UTrack; 21 | import com.umeng.message.UmengMessageHandler; 22 | import com.umeng.message.UmengNotificationClickHandler; 23 | import com.umeng.message.common.inter.ITagManager; 24 | import com.umeng.message.entity.UMessage; 25 | import com.umeng.message.inapp.IUmengInAppMsgCloseCallback; 26 | import com.umeng.message.inapp.InAppMessageManager; 27 | import com.umeng.message.tag.TagManager; 28 | 29 | import org.android.agoo.huawei.HuaWeiRegister; 30 | import org.android.agoo.mezu.MeizuRegister; 31 | import org.android.agoo.oppo.OppoRegister; 32 | import org.android.agoo.vivo.VivoRegister; 33 | import org.android.agoo.xiaomi.MiPushRegistar; 34 | import org.json.JSONObject; 35 | 36 | import java.util.ArrayList; 37 | import java.util.Arrays; 38 | import java.util.HashMap; 39 | import java.util.HashSet; 40 | import java.util.List; 41 | import java.util.Map; 42 | import java.util.Set; 43 | 44 | import io.flutter.app.FlutterApplication; 45 | import io.flutter.plugin.common.EventChannel; 46 | import io.flutter.plugin.common.MethodCall; 47 | import io.flutter.plugin.common.MethodChannel; 48 | import io.flutter.plugin.common.MethodChannel.MethodCallHandler; 49 | import io.flutter.plugin.common.MethodChannel.Result; 50 | import io.flutter.plugin.common.PluginRegistry; 51 | import io.flutter.plugin.common.PluginRegistry.Registrar; 52 | import io.flutter.view.FlutterNativeView; 53 | 54 | import static android.os.Looper.getMainLooper; 55 | 56 | /** 57 | * FlutterFaiUmengPlugin 58 | */ 59 | public class FlutterFaiUmengPlugin { 60 | 61 | 62 | 63 | /** 64 | * Plugin registration. 65 | */ 66 | public static void registerWith(Registrar registrar) { 67 | 68 | Context lContext = registrar.context(); 69 | /** 70 | * 注册消息监听通道 71 | */ 72 | MessageChannelItem.getInstance().messageChannelFunction(registrar.messenger(), lContext); 73 | 74 | 75 | registrar.addViewDestroyListener(new PluginRegistry.ViewDestroyListener() { 76 | @Override 77 | public boolean onViewDestroy(FlutterNativeView view) { 78 | return false; 79 | } 80 | }); 81 | } 82 | 83 | 84 | // private FlutterFaiUmengPlugin(Registrar registrar, MethodChannel channel) { 85 | // this.registrar = registrar; 86 | // this.channel = channel; 87 | // this.callbackMap = new HashMap<>(); 88 | // instance = this; 89 | // } 90 | // 91 | // 92 | // @Override 93 | // public void onMethodCall(MethodCall call, Result result) { 94 | // Log.i(TAG, call.method); 95 | // if (call.method.equals("getPlatformVersion")) { 96 | // result.success("Android " + android.os.Build.VERSION.RELEASE); 97 | // } else if (call.method.equals("init")) { 98 | // init(call, result); 99 | // } else if (call.method.equals("addTags")) { 100 | // addTags(call, result); 101 | // } else if (call.method.equals("deleteTags")) { 102 | // deleteTags(call, result); 103 | // } else if (call.method.equals("getAllTags")) { 104 | // getAllTags(call, result); 105 | // } else if (call.method.equals("setAlias")) { 106 | // setAlias(call, result); 107 | // } else if (call.method.equals("addAlias")) { 108 | // addAlias(call, result); 109 | // } else if (call.method.equals("deleteAlias")) { 110 | // deleteAlias(call, result); 111 | // } else if (call.method.equals("stopPush")) { 112 | // stopPush(call, result); 113 | // } else if (call.method.equals("openPush")) { 114 | // openPush(call, result); 115 | // } else if (call.method.equals("setNotificaitonOnForeground")) { 116 | // setNotificaitonOnForeground(call, result); 117 | // } else if (call.method.equals("setCustomMessageStyle")) { 118 | //// setCustomMessageStyle(call, result); 119 | // } else if (call.method.equals("handleMessage")) { 120 | //// handleMessage(call, result); 121 | // } else if (call.method.equals("setDisplayNotificationNumber")) { 122 | // setDisplayNotificationNumber(call, result); 123 | // } else if (call.method.equals("setNotificationPlaySound")) { 124 | // setNotificationPlaySound(call, result); 125 | // } else if (call.method.equals("setNotificationLights")) { 126 | // setNotificationLights(call, result); 127 | // } else if (call.method.equals("setNotificationPlayVibrate")) { 128 | // setNotificationPlayVibrate(call, result); 129 | // } else if (call.method.equals("setNoDisturbMode")) { 130 | // setNoDisturbMode(call, result); 131 | // } else if (call.method.equals("setMuteDurationSeconds")) { 132 | // setMuteDurationSeconds(call, result); 133 | // } else if (call.method.equals("setResourcePackageName")) { 134 | // setResourcePackageName(call, result); 135 | // } else if (call.method.equals("setInAppMsgDebugMode")) { 136 | // setInAppMsgDebugMode(call, result); 137 | // } else if (call.method.equals("setSplashMessage")) { 138 | // setSplashMessage(call, result); 139 | // } else if (call.method.equals("showCardMessage")) { 140 | // showCardMessage(call, result); 141 | // } else if (call.method.equals("setPushCheck")) { 142 | // setPushCheck(call, result); 143 | // } else { 144 | // result.notImplemented(); 145 | // } 146 | // } 147 | // 148 | // // 主线程再返回数据 149 | // public void runMainThread(final Map map, final Result result, final String method) { 150 | // Log.d(TAG, "runMainThread:" + "map = " + map + ",method =" + method); 151 | // android.os.Handler handler = new Handler(getMainLooper()); 152 | // handler.post(new Runnable() { 153 | // @Override 154 | // public void run() { 155 | // if (result == null && method != null) { 156 | // channel.invokeMethod(method, map); 157 | // } else { 158 | // result.success(map); 159 | // } 160 | // } 161 | // }); 162 | // } 163 | // 164 | // 165 | // /** 166 | // * 初始化UMPush 167 | // * 在此处调用基础组件包提供的初始化函数 相应信息可在应用管理 -> 应用信息 中找到 http://message.umeng.com/list/apps 168 | // * 参数一:当前上下文context; 169 | // * 参数二:应用申请的Appkey(需替换); 170 | // * 参数三:渠道名称; 171 | // * 参数四:设备类型,必须参数,传参数为UMConfigure.DEVICE_TYPE_PHONE则表示手机;传参数为UMConfigure.DEVICE_TYPE_BOX则表示盒子;默认为手机; 172 | // * 参数五:Push推送业务的secret 填充Umeng Message Secret对应信息(需替换) 173 | // * 174 | // * @param call 175 | // * @param result 176 | // */ 177 | // public void init(MethodCall call, final Result result) { 178 | // Log.d(TAG, "setup :" + call.arguments); 179 | // HashMap map = call.arguments(); 180 | // String umAppkey = (String) map.get("umAppkey"); 181 | // String umSecret = (String) map.get("umSecret"); 182 | // String miAppId = (String) map.get("miAppId"); 183 | // String miAppKey = (String) map.get("miAppKey"); 184 | // String mzAppId = (String) map.get("mzAppId"); 185 | // String mzAppKey = (String) map.get("mzAppKey"); 186 | // String opAppKey = (String) map.get("opAppKey"); 187 | // String opAppSecret = (String) map.get("opAppSecret"); 188 | // 189 | // UMConfigure.init(this, umAppkey, "Umeng", UMConfigure.DEVICE_TYPE_PHONE, umSecret); 190 | // 191 | // //获取消息推送代理示例 192 | // mPushAgent = PushAgent.getInstance(this); 193 | // //注册推送服务,每次调用register方法都会回调该接口 194 | // mPushAgent.register(new IUmengRegisterCallback() { 195 | // 196 | // @Override 197 | // public void onSuccess(String deviceToken) { 198 | // //注册成功会返回deviceToken deviceToken是推送消息的唯一标志 199 | // Log.i(TAG, "注册成功:deviceToken:--------> " + deviceToken); 200 | // result.success("注册成功" + deviceToken); 201 | // } 202 | // 203 | // @Override 204 | // public void onFailure(String s, String s1) { 205 | // Log.e(TAG, "注册失败:--------> " + "s:" + s + ",s1:" + s1); 206 | // result.error("注册失败", s, s1); 207 | // } 208 | // }); 209 | // 210 | // mPushAgent.setMessageHandler(messageHandler); 211 | // 212 | // mPushAgent.setNotificationClickHandler(notificationClickHandler); 213 | // 214 | // 215 | // /** 216 | // * 初始化厂商通道 217 | // */ 218 | // //小米通道 219 | // MiPushRegistar.register(this, miAppId, miAppKey); 220 | // //华为通道,注意华为通道的初始化参数在minifest中配置 221 | // HuaWeiRegister.register(this); 222 | // //魅族通道 223 | // MeizuRegister.register(this, mzAppId, mzAppKey); 224 | // //OPPO通道 225 | // OppoRegister.register(this, opAppKey, opAppSecret); 226 | // //VIVO 通道,注意VIVO通道的初始化参数在minifest中配置 227 | // VivoRegister.register(this); 228 | // 229 | // } 230 | // 231 | // 232 | // /** 233 | // * 添加标签 示例:将“标签1”、“标签2”绑定至该设备 234 | // * 235 | // * @param call 236 | // * @param result0 237 | // */ 238 | // public void addTags(final MethodCall call, final Result result0) { 239 | // Log.d(TAG, "addTags: " + call.arguments); 240 | // 241 | // List tagList = call.arguments(); 242 | // final Set tags = new HashSet<>(tagList); 243 | // mPushAgent.getTagManager().addTags(new TagManager.TCallBack() { 244 | // @Override 245 | // public void onMessage(boolean b, ITagManager.Result result) { 246 | // result0.success("addTags" + tags.toString() + b); 247 | // 248 | // } 249 | // }, tags.toString()); 250 | // } 251 | // 252 | // 253 | // /** 254 | // * 删除标签,将之前添加的标签中的一个或多个删除 255 | // * 256 | // * @param call 257 | // * @param result0 258 | // */ 259 | // public void deleteTags(MethodCall call, final Result result0) { 260 | // Log.d(TAG, "deleteTags: " + call.arguments); 261 | // 262 | // List tagList = call.arguments(); 263 | // final Set tags = new HashSet<>(tagList); 264 | // mPushAgent.getTagManager().deleteTags(new TagManager.TCallBack() { 265 | // @Override 266 | // public void onMessage(final boolean isSuccess, final ITagManager.Result result) { 267 | // result0.success("deleteTags" + tags.toString() + isSuccess); 268 | // } 269 | // }, "标签1", "标签2"); 270 | // } 271 | // 272 | // /** 273 | // * 获取服务器端的所有标签 274 | // * 275 | // * @param call 276 | // * @param result0 277 | // */ 278 | // public void getAllTags(MethodCall call, final Result result0) { 279 | // Log.d(TAG, "getAllTags: "); 280 | // mPushAgent.getTagManager().getTags(new TagManager.TagListCallBack() { 281 | // @Override 282 | // public void onMessage(boolean isSuccess, List result) { 283 | // result0.success("getAllTags:" + isSuccess); 284 | // } 285 | // }); 286 | // } 287 | // 288 | // /** 289 | // * 别名绑定,将某一类型的别名ID绑定至某设备,老的绑定设备信息被覆盖,别名ID和deviceToken是一对一的映射关系 290 | // * 291 | // * @param call 292 | // * @param result0 293 | // */ 294 | // public void setAlias(MethodCall call, final Result result0) { 295 | // Log.d(TAG, "setAlias: " + call.arguments); 296 | // String alias = call.arguments(); 297 | // mPushAgent.setAlias(alias, "自定义类型", new UTrack.ICallBack() { 298 | // @Override 299 | // public void onMessage(boolean isSuccess, String message) { 300 | // result0.success("setAlias:" + isSuccess); 301 | // 302 | // } 303 | // }); 304 | // 305 | // } 306 | // 307 | // /** 308 | // * 别名增加,将某一类型的别名ID绑定至某设备,老的绑定设备信息还在,别名ID和device_token是一对多的映射关系 309 | // * 310 | // * @param call 311 | // * @param result0 312 | // */ 313 | // public void addAlias(MethodCall call, final Result result0) { 314 | // Log.d(TAG, "addAlias: " + call.arguments); 315 | // 316 | // String alias = call.arguments(); 317 | // mPushAgent.addAlias(alias, "自定义类型", new UTrack.ICallBack() { 318 | // @Override 319 | // public void onMessage(boolean isSuccess, String message) { 320 | // result0.success("addAlias:" + isSuccess); 321 | // } 322 | // }); 323 | // 324 | // } 325 | // 326 | // /** 327 | // * 移除别名ID 328 | // * 329 | // * @param call 330 | // * @param result0 331 | // */ 332 | // public void deleteAlias(MethodCall call, final Result result0) { 333 | // Log.d(TAG, "deleteAlias:"); 334 | // String alias = call.arguments(); 335 | // mPushAgent.deleteAlias(alias, "自定义类型", new UTrack.ICallBack() { 336 | // @Override 337 | // public void onMessage(boolean isSuccess, String message) { 338 | // result0.success("deleteAlias:" + isSuccess); 339 | // } 340 | // }); 341 | // } 342 | // 343 | // 344 | // /** 345 | // * 如果您的应用在前台,您可以设置不显示通知栏消息。默认情况下,应用在前台是显示通知的。 开发者更改前台通知显示设置后,会根据更改生效 346 | // * 此方法请在mPushAgent.register方法之前调用。 347 | // * 348 | // * @param call 349 | // * @param result 350 | // */ 351 | // public void setNotificaitonOnForeground(MethodCall call, Result result) { 352 | // Log.d(TAG, "setNotificaitonOnForeground:"); 353 | // boolean isForeground = call.arguments(); 354 | // mPushAgent.setNotificaitonOnForeground(isForeground); 355 | // } 356 | // 357 | // 358 | // /** 359 | // * 在PushSDK里,UmengMessageHandler类负责处理消息,包括通知和自定义消息。其中,成员函数getNotification负责定义通知栏样式。 360 | // * 若SDK默认的消息展示样式不符合开发者的需求,可通过覆盖该方法来自定义通知栏展示样式 361 | // * 每当有通知送达时,均会回调getNotification方法,因此可以通过监听此方法来判断通知是否送达。 362 | // * msg.builder_id是服务器下发的消息字段,用来指定通知消息的样式 363 | // *

364 | // * 消息到达时获取自定义参数。重写UmengMessageHandler类中的getNotification(Context context, UMessage msg)方法: 365 | // * 自定义消息 366 | // * for (Map.Entry entry : msg.extra.entrySet()) { 367 | // * Object key = entry.getKey(); 368 | // * Object value = entry.getValue(); 369 | // * } 370 | // * 371 | // * @param call 372 | // * @param result 373 | // */ 374 | // 375 | // UmengMessageHandler messageHandler = new UmengMessageHandler() { 376 | // 377 | // @Override 378 | // public Notification getNotification(Context context, UMessage msg) { 379 | //// result.success(msg.getRaw()); 380 | // Log.d(TAG + "Message", msg.getRaw().toString()); 381 | // 382 | // switch (msg.builder_id) { 383 | // case 1: 384 | //// Notification.Builder builder = new Notification.Builder(context); 385 | //// 自定义消息样式 386 | //// RemoteViews myNotificationView = new RemoteViews(context.getPackageName(), 387 | //// R.layout.notification_view); 388 | //// myNotificationView.setTextViewText(R.id.notification_title, msg.title); 389 | //// myNotificationView.setTextViewText(R.id.notification_text, msg.text); 390 | //// myNotificationView.setImageViewBitmap(R.id.notification_large_icon, 391 | //// getLargeIcon(context, msg)); 392 | //// myNotificationView.setImageViewResource(R.id.notification_small_icon, 393 | //// getSmallIconId(context, msg)); 394 | //// builder.setContent(myNotificationView) 395 | //// .setSmallIcon(getSmallIconId(context, msg)) 396 | //// .setTicker(msg.ticker) 397 | //// .setAutoCancel(true); 398 | // return null; 399 | // default: 400 | // //默认为0,若填写的builder_id并不存在,也使用默认。 401 | // return super.getNotification(context, msg); 402 | // } 403 | // } 404 | // }; 405 | // 406 | // 407 | // /** 408 | // * 开发者可自定义用户点击通知栏时的后续动作。自定义行为的数据放在UMessage.custom字段。 409 | // * 在【友盟+】后台或通过API发送消息时,在“后续动作”中的“自定义行为”中输入相应的值或代码即可实现。 410 | // * 若开发者需要处理自定义行为,则可以重写方法dealWithCustomAction()。其中自定义行为的内容,存放在UMessage.custom中 411 | // *

412 | // * 消息点击时获取自定义参数。通过重写UmengNotificationClickHandler类中的launchApp、openUrl、 413 | // * openActivity、dealWithCustomAction方法,均可以从msg.extra中获取自定义参数: 414 | // *

415 | // * 进入Activity时获取自定义参数。若您使用Push SDK的默认设置处理通知消息,则从服务端传的自定义参数将会通过Intent传递给相应的Activity 416 | // * 您可以在相应的Activity中的onResume()方法内通过以下代码获得传递的参数 417 | // *

418 | // * Bundle bun = getIntent().getExtras(); 419 | // * if (bun != null) { 420 | // * Set keySet = bun.keySet(); 421 | // * for (String key : keySet) { 422 | // * String value = bun.getString(key); 423 | // * ... 424 | // * } 425 | // * } 426 | // * 注意:如果在Activity中获取自定义参数,则需要将该Activity的launchMode设置为android:launchMode=”singleTask”,并重写onNewIntent方法: 427 | // * 428 | // * @param call 429 | // * @param result 430 | // * @Override protected void onNewIntent(Intent intent) { 431 | // * super.onNewIntent(intent); 432 | // * setIntent(intent); 433 | // * } 434 | // *

435 | // * 自定义消息不是通知,默认不会被SDK展示到通知栏上,【友盟+】推送仅负责将消息透传给SDK,其内容和展示形式是则完全可以由开发者自己定义。 436 | // * 若开发者要使用自定义消息,则需重在自定义Application类的onCreate() 中重写dealWithCustomMessage()方法, 437 | // * 自定义消息的内容存放在UMessage.custom字段里。代码如下所示: 438 | // * UmengMessageHandler messageHandler = new UmengMessageHandler(){ 439 | // * @Override public void dealWithCustomMessage(final Context context, final UMessage msg) { 440 | // * new Handler(getMainLooper()).post(new Runnable() { 441 | // * @Override public void run() { 442 | // * // 对于自定义消息,PushSDK默认只统计送达。若开发者需要统计点击和忽略,则需手动调用统计方法。 443 | // * boolean isClickOrDismissed = true; 444 | // * if(isClickOrDismissed) { 445 | // * //自定义消息的点击统计 446 | // * UTrack.getInstance(getApplicationContext()).trackMsgClick(msg); 447 | // * } else { 448 | // * //自定义消息的忽略统计 449 | // * UTrack.getInstance(getApplicationContext()).trackMsgDismissed(msg); 450 | // * } 451 | // * Toast.makeText(context, msg.custom, Toast.LENGTH_LONG).show(); 452 | // * } 453 | // * }); 454 | // * } 455 | // * }; 456 | // * mPushAgent.setMessageHandler(messageHandler); 457 | // */ 458 | // 459 | // UmengNotificationClickHandler notificationClickHandler = new UmengNotificationClickHandler() { 460 | // @Override 461 | // public void dealWithCustomAction(Context context, UMessage msg) { 462 | //// result.success(msg.getRaw()); 463 | // Log.d(TAG + "handleMessage", msg.getRaw().toString()); 464 | // 465 | // } 466 | // 467 | // 468 | // @Override 469 | // public void launchApp(Context context, UMessage msg) { 470 | // super.launchApp(context, msg); 471 | // } 472 | // 473 | // @Override 474 | // public void openUrl(Context context, UMessage msg) { 475 | // super.openUrl(context, msg); 476 | // } 477 | // 478 | // @Override 479 | // public void openActivity(Context context, UMessage msg) { 480 | // super.openActivity(context, msg); 481 | // } 482 | // }; 483 | // 484 | // 485 | //// } 486 | // 487 | // /** 488 | // * 设置通知栏显示数量 489 | // * 通知栏可以设置最多显示通知的条数,当通知栏显示数目大于设置值,此时再有新通知到达时,会把旧的一条通知隐藏。 490 | // * 参数number可以设置为0~10之间任意整数。当参数为0时,表示不合并通知; 491 | // * 当该方法存在多次调用时,一最后一次调用时的设置为准。 492 | // * 493 | // * @param call 494 | // * @param result 495 | // */ 496 | // public void setDisplayNotificationNumber(MethodCall call, Result result) { 497 | // Log.d(TAG, "setDisplayNotificationNumber:"); 498 | // int number = call.arguments(); 499 | // mPushAgent.setDisplayNotificationNumber(number); 500 | // } 501 | // 502 | // 503 | // /** 504 | // * 通知响铃、震动及呼吸灯控制 505 | // * 响铃、 506 | // * 1、服务端控制:通过服务端推送状态来设置通知到达后响铃、震动、呼吸灯的状态; 507 | // * 2、客户端控制:关闭服务端推送控制能力,由客户端控制通知到达后是否响铃、震动以及呼吸灯是否点亮; 508 | // * 3、客户端控制:客户端禁止; 509 | // * 510 | // * @param call 511 | // * @param result 512 | // */ 513 | // public void setNotificationPlaySound(MethodCall call, Result result) { 514 | // Log.d(TAG, "setNotificationPlaySound:"); 515 | // int type = call.arguments(); 516 | // if (type == 1) { 517 | // mPushAgent.setNotificationPlaySound(MsgConstant.NOTIFICATION_PLAY_SERVER); 518 | // } else if (type == 2) { 519 | // mPushAgent.setNotificationPlaySound(MsgConstant.NOTIFICATION_PLAY_SDK_ENABLE); 520 | // } else { 521 | // mPushAgent.setNotificationPlaySound(MsgConstant.NOTIFICATION_PLAY_SDK_DISABLE); 522 | // } 523 | // 524 | // } 525 | // 526 | // /** 527 | // * 通知响铃、震动及呼吸灯控制 528 | // * 呼吸灯 529 | // * 1、服务端控制:通过服务端推送状态来设置通知到达后响铃、震动、呼吸灯的状态; 530 | // * 2、客户端控制:关闭服务端推送控制能力,由客户端控制通知到达后是否响铃、震动以及呼吸灯是否点亮; 531 | // * 3、客户端控制:客户端禁止; 532 | // * 533 | // * @param call 534 | // * @param result 535 | // */ 536 | // public void setNotificationLights(MethodCall call, Result result) { 537 | // Log.d(TAG, "setNotificationLights:"); 538 | // int type = call.arguments(); 539 | // if (type == 1) { 540 | // mPushAgent.setNotificationPlayLights(MsgConstant.NOTIFICATION_PLAY_SERVER); 541 | // } else if (type == 2) { 542 | // mPushAgent.setNotificationPlayLights(MsgConstant.NOTIFICATION_PLAY_SDK_ENABLE); 543 | // } else { 544 | // mPushAgent.setNotificationPlayLights(MsgConstant.NOTIFICATION_PLAY_SDK_DISABLE); 545 | // } 546 | // 547 | // } 548 | // 549 | // /** 550 | // * 通知响铃、震动及呼吸灯控制 551 | // * 震动: 552 | // * 1、服务端控制:通过服务端推送状态来设置通知到达后响铃、震动、呼吸灯的状态; 553 | // * 2、客户端控制:关闭服务端推送控制能力,由客户端控制通知到达后是否响铃、震动以及呼吸灯是否点亮; 554 | // * 3、客户端控制:客户端禁止; 555 | // * 556 | // * @param call 557 | // * @param result 558 | // */ 559 | // public void setNotificationPlayVibrate(MethodCall call, Result result) { 560 | // Log.d(TAG, "setNotificationPlayVibrate:"); 561 | // int type = call.arguments(); 562 | // if (type == 1) { 563 | // mPushAgent.setNotificationPlayVibrate(MsgConstant.NOTIFICATION_PLAY_SERVER); 564 | // } else if (type == 2) { 565 | // mPushAgent.setNotificationPlayVibrate(MsgConstant.NOTIFICATION_PLAY_SDK_ENABLE); 566 | // } else { 567 | // mPushAgent.setNotificationPlayVibrate(MsgConstant.NOTIFICATION_PLAY_SDK_DISABLE); 568 | // } 569 | // } 570 | // 571 | // 572 | // /** 573 | // * 通知免打扰模式 574 | // * 为免过度打扰用户,SDK默认在“23:00”到“7:00”之间收到通知消息时不响铃,不振动,不闪灯。 575 | // * 如果需要改变默认的静音时间,可以使用以下接口 576 | // *

577 | // * 可以通过下面的设置,来关闭免打扰模式: 578 | // * mPushAgent.setNoDisturbMode(0, 0, 0, 0); 579 | // * 580 | // * @param call 581 | // * @param result 582 | // */ 583 | // public void setNoDisturbMode(MethodCall call, Result result) { 584 | // Log.d(TAG, "setNoDisturbMode:"); 585 | // HashMap map = call.arguments(); 586 | // int startHour = (int) map.get("startHour"); 587 | // int startMinute = (int) map.get("startMinute"); 588 | // int endHour = (int) map.get("endHour"); 589 | // int endMinute = (int) map.get("endMinute"); 590 | // mPushAgent.setNoDisturbMode(startHour, startMinute, endHour, endMinute); 591 | // } 592 | // 593 | // 594 | // /** 595 | // * 通知免打扰模式 596 | // * 默认情况下,同一台设备在1分钟内收到同一个应用的多条通知时,不会重复提醒,同时在通知栏里新的通知会替换掉旧的通知。 597 | // * 可以通过如下方法来设置冷却时间: 598 | // * 599 | // * @param call 600 | // * @param result 601 | // */ 602 | // public void setMuteDurationSeconds(MethodCall call, Result result) { 603 | // Log.d(TAG, "setMuteDurationSeconds:"); 604 | // int seconds = call.arguments(); 605 | // mPushAgent.setMuteDurationSeconds(seconds); 606 | // } 607 | // 608 | // /** 609 | // * 自定义资源包名 610 | // * Android Studio开发工具是基于gradle的配置方式,资源文件的包和应用程序的包是可以分开的, 611 | // * 为了正确的找到资源包名,为开发者提供了自定义的设置资源包的接口。当资源包名和应用程序包名不一致时,调用设置资源包名的接口: 612 | // * 613 | // * @param call 614 | // * @param result 615 | // */ 616 | // public void setResourcePackageName(MethodCall call, Result result) { 617 | // Log.d(TAG, "setResourcePackageName:"); 618 | // String packageName = call.arguments(); 619 | // mPushAgent.setResourcePackageName(packageName); 620 | // } 621 | // 622 | // /** 623 | // * 应用内消息控制 624 | // * 应用内消息默认为线上模式,如需使用测试模式, 625 | // * 626 | // * @param call 627 | // * @param result 628 | // */ 629 | // public void setInAppMsgDebugMode(MethodCall call, Result result) { 630 | // Log.d(TAG, "setInAppMsgDebugMode :" + call.arguments); 631 | // boolean debug = (boolean) call.arguments; 632 | // InAppMessageManager.getInstance(registrar.context()).setInAppMsgDebugMode(debug); 633 | // } 634 | // 635 | // 636 | // /** 637 | // * 全屏消息 638 | // * 全屏消息是App首次启动打开进入的页面,以全屏图片的形式展示 639 | // * 640 | // * @param call 641 | // * @param result 1、在主工程的values目录下的styles.xml文件中添加如下代码, 642 | // * 并在drawable目录下放置一张名为umeng\_push\_default\_splash\_bg的默认图片(推荐1920*1080分辨率,也可以根据适配需要引用xml资源)。 643 | // * 646 | // *

647 | // * 2、新建一个Activity,继承自UmengSplashMessageActivity,重写onCustomPretreatment方法,并设置全屏消息默认跳转Activity的路径,例如: 648 | // * public class SplashTestActivity extends UmengSplashMessageActivity { 649 | // * @Override public boolean onCustomPretreatment() { 650 | // * InAppMessageManager mInAppMessageManager = InAppMessageManager.getInstance(this); 651 | // * //设置应用内消息为Debug模式 652 | // * mInAppMessageManager.setInAppMsgDebugMode(true); 653 | // * //参数为Activity的完整包路径,下面仅是示例代码,请按实际需求填写 654 | // * mInAppMessageManager.setMainActivityPath("com.umeng.message.example.MainActivity"); 655 | // * return super.onCustomPretreatment(); 656 | // * } 657 | // * } 658 | // * 说明:onCustomPretreatment方法默认的返回值为false,返回false则会走全屏消息的默认逻辑。 659 | // * 若开发者在全屏消息的Activity里有动态申请权限的需求,则可以在onCustomPretreatment内进行处理,并return true,则全屏消息逻辑不会继续执行 660 | // *

661 | // * 3、在主工程的AndroidManifest.xml中的标签下注册Activity,并将其配置为App首次启动打开的Activity, 662 | // * theme设置为步骤1所写的Theme_Umeng_Push_Splash,例如: 663 | // * 667 | // * 668 | // * 669 | // *

670 | // * 671 | // * 672 | // * 673 | // *

674 | // * 说明: 675 | // *

676 | // * 生产模式请求服务器的最小间隔是30分钟,测试模式的最小间隔是1秒。 677 | // * 全屏消息默认的逻辑为显示2s默认图片,若在2s内请求到全屏消息,则展示全屏消息,否则就跳转到开发者设置的页面。 678 | // * 全屏消息的图片会自动缓存,并在有新消息到来时,删除旧消息的缓存。 679 | // */ 680 | // public void setSplashMessage(MethodCall call, Result result) { 681 | // Log.d(TAG, "setSplashMessage:"); 682 | // } 683 | // 684 | // 685 | // /** 686 | // * 插屏消息 687 | // * 插屏消息是在App页面之上弹出的图片或文本消息。插屏消息分为三种类型:插屏、自定义插屏和纯文本。 688 | // *

689 | // * 说明: 690 | // *

691 | // * label是插屏消息的标签,用来标识该消息。 692 | // * 客户端需先调用showCardMessage,把label发送到服务器,之后U-Push后台【展示位置】才会出现可选label。 693 | // * 以label为单位,生产模式请求服务器的最小间隔是30分钟,测试模式的最小间隔是1秒。 694 | // * 插屏消息的图片会自动缓存,并在有新消息到来时,删除旧消息的缓存。 695 | // * 注意:安装到设备上后,每个版本(versionCode)的App最多打10个标签。 696 | // *

697 | // * 自定义插屏 698 | // * 自定义插屏允许开发者来控制插屏的展示样式。若要使用自定义插屏样式,则需在工程中新建一个命名为umeng_custom_card_message.xml的布局文件, 699 | // * 开发者可以随意修改布局(ImageView和两个Button的id不能改变)。例如: 700 | // * 701 | // * 707 | // *

708 | // * 713 | // *

714 | // * 718 | // *

719 | // * 724 | // *

725 | // *