# ali_plugin **Repository Path**: john_tp/Flutter-ali_plugin ## Basic Information - **Project Name**: ali_plugin - **Description**: 插件包含如下几个功能: 支付宝授权 支付宝订单支付 阿里云移动推送 阿里日志服务 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2022-09-30 - **Last Updated**: 2024-06-25 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # ali_plugin A new Flutter plugin 阿里功能插件 ## Getting Started ### 插件包含如下几个功能: 1. 支付宝授权 2. 支付宝订单支付 3. 阿里云移动推送 4. 阿里日志服务 ### 集成方法 - 在pubspec.yaml中增加如下代码,再执行flutter pub get ``` #阿里支付宝授权、支付、推送 ali_plugin: git: url: https://gitee.com/john_tp/Flutter-ali_plugin.git ref: 3.2.1 ``` - android端集成配置 * 配置flutterDemo/android/build.gradle ``` allprojects { repositories { ... flatDir { dirs project(':ali_plugin').file('libs') //日志 dirs project(':ali_log').file('libs') } ... } } ``` * 使用日志功能需要在app/build.gradle中增加如下3个依赖库 ``` dependencies { //日志依赖库 implementation 'com.alibaba:fastjson:1.2.73' implementation 'org.greenrobot:greendao:3.3.0' implementation 'com.squareup.okhttp3:okhttp:4.8.1' } ``` * 使用自定义application ``` public class MyApp extends FlutterApplication { @java.lang.Override public void onCreate() { initHa(); AliPlugin.init(this, aliAppKey, aliSecretKey); initLog(); GlobalThreadManager.runInUiThreadDelayed(new Runnable() { @Override public void run() { FlutterMain.startInitialization(MyApp.this); } }, 1500); } private void initLog() { AliLogConfig config = new AliLogConfig(); config.endpoint = "cn-shenzhen.log.aliyuncs.com"; config.project = "xx"; config.logStore = "xx"; config.AK = "your AK"; //子账号AK config.SK = "your SK"; //子账号SK config.context = getApplicationContext(); config.appName = "Flutter_阿里日志Demo"; //app名 config.apiEnv = "Debug"; //api环境 config.terminal = "01"; //平台编码 AliLogManager.setLogOpen(true); AliLogManager.init(config); } private void initHa() { AliHaConfig config = new AliHaConfig(); config.appKey = aliAppKey; config.appVersion = BuildConfig.VERSION_NAME; config.appSecret = aliSecretKey; //渠道(字母数字非中文) config.channel = "android"; //昵称(字母数字非中文) config.userNick = null; config.application = this; config.context = getApplicationContext(); config.isAliyunos = false; //启动CrashReporter AliCrashReportPlugin.init(config); } } ``` * 更改AndroidManifest.xml配置 ``` ``` - ios端集成配置 * 项目的pubspec.yaml文件底部加上 ``` ali_plugin: ios: noutdid ``` * 配置xxx.xcconfig文件(文件名自定义,如有类似文件可直接添加一行; 也可以Add User-Defined Setting) ``` ALI_PAY_SCHEME=alipay${你的appid} ``` * 在Debug.xcconfig和Release.xcconfig中插入一行 ``` #include "xxx.xcconfig" ``` * 配置info.plist ``` CFBundleURLTypes CFBundleTypeRole Editor CFBundleURLSchemes $(ALI_PAY_SCHEME) ALI_PAY_SCHEME $(ALI_PAY_SCHEME) [//]: # (LSApplicationQueriesSchemes中新增一行) $(ALI_PAY_SCHEME) ``` * 更多使用详情请参考example子项目 This project is a starting point for a Flutter [plug-in package](https://flutter.dev/developing-packages/), a specialized package that includes platform-specific implementation code for Android and/or iOS. For help getting started with Flutter, view our [online documentation](https://flutter.dev/docs), which offers tutorials, samples, guidance on mobile development, and a full API reference.