Commit c1027828 authored by xgz's avatar xgz

Initial commit

parents
.DS_Store
.dart_tool/
.packages
.pub/
build/
# Default ignored files
/shelf/
/workspace.xml
<component name="libraryTable">
<library name="Dart SDK">
<CLASSES>
<root url="file:///Users/xgz/Documents/Flutter/bin/cache/dart-sdk/lib/async" />
<root url="file:///Users/xgz/Documents/Flutter/bin/cache/dart-sdk/lib/collection" />
<root url="file:///Users/xgz/Documents/Flutter/bin/cache/dart-sdk/lib/convert" />
<root url="file:///Users/xgz/Documents/Flutter/bin/cache/dart-sdk/lib/core" />
<root url="file:///Users/xgz/Documents/Flutter/bin/cache/dart-sdk/lib/developer" />
<root url="file:///Users/xgz/Documents/Flutter/bin/cache/dart-sdk/lib/html" />
<root url="file:///Users/xgz/Documents/Flutter/bin/cache/dart-sdk/lib/io" />
<root url="file:///Users/xgz/Documents/Flutter/bin/cache/dart-sdk/lib/isolate" />
<root url="file:///Users/xgz/Documents/Flutter/bin/cache/dart-sdk/lib/math" />
<root url="file:///Users/xgz/Documents/Flutter/bin/cache/dart-sdk/lib/mirrors" />
<root url="file:///Users/xgz/Documents/Flutter/bin/cache/dart-sdk/lib/typed_data" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</component>
\ No newline at end of file
<component name="libraryTable">
<library name="Flutter Plugins" type="FlutterPluginsLibraryType">
<CLASSES>
<root url="file://$PROJECT_DIR$" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</component>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectType">
<option name="id" value="io.flutter" />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/flutter_meiqia.iml" filepath="$PROJECT_DIR$/flutter_meiqia.iml" />
<module fileurl="file://$PROJECT_DIR$/android/flutter_meiqia_android.iml" filepath="$PROJECT_DIR$/android/flutter_meiqia_android.iml" />
<module fileurl="file://$PROJECT_DIR$/example/android/flutter_meiqia_example_android.iml" filepath="$PROJECT_DIR$/example/android/flutter_meiqia_example_android.iml" />
</modules>
</component>
</project>
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="example/lib/main.dart" type="FlutterRunConfigurationType" factoryName="Flutter">
<option name="filePath" value="$PROJECT_DIR$/example/lib/main.dart" />
<method />
</configuration>
</component>
\ No newline at end of file
# 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: 1aafb3a8b9b0c36241c5f5b34ee914770f015818
channel: unknown
project_type: plugin
## 0.0.1
* TODO: Describe initial release.
TODO: Add your license here.
# flutter_meiqia
美恰客服
## Getting Started
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.
*.iml
.gradle
/local.properties
/.idea/workspace.xml
/.idea/libraries
.DS_Store
/build
/captures
group 'com.example.flutter_meiqia'
version '1.0'
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.0'
}
}
rootProject.allprojects {
repositories {
google()
jcenter()
}
}
apply plugin: 'com.android.library'
android {
compileSdkVersion 29
defaultConfig {
minSdkVersion 16
}
lintOptions {
disable 'InvalidPackage'
}
}
dependencies{
implementation 'com.meiqia:meiqiasdk:+'
implementation 'com.android.support:support-v4:23.1.1'
implementation 'com.squareup.okhttp3:okhttp:3.5.0'
implementation 'com.nostra13.universalimageloader:universal-image-loader:1.9.5'
implementation 'com.squareup.picasso:picasso:2.5.2'
}
org.gradle.jvmargs=-Xmx1536M
android.useAndroidX=true
android.enableJetifier=true
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-all.zip
rootProject.name = 'flutter_meiqia'
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.flutter_meiqia">
</manifest>
package com.example.flutter_meiqia;
import android.app.Activity;
import android.content.Intent;
import androidx.annotation.NonNull;
import com.meiqia.core.MQManager;
import com.meiqia.core.callback.OnInitCallback;
import com.meiqia.meiqiasdk.util.MQConfig;
import com.meiqia.meiqiasdk.util.MQIntentBuilder;
import java.util.Map;
import io.flutter.embedding.engine.plugins.FlutterPlugin;
import io.flutter.embedding.engine.plugins.activity.ActivityAware;
import io.flutter.embedding.engine.plugins.activity.ActivityPluginBinding;
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;
/** FlutterMeiqiaPlugin */
public class FlutterMeiqiaPlugin implements FlutterPlugin, MethodCallHandler, ActivityAware {
/// 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;
private Activity context;
@Override
public void onAttachedToEngine(@NonNull FlutterPluginBinding flutterPluginBinding) {
channel = new MethodChannel(flutterPluginBinding.getBinaryMessenger(), "flutter_meiqia");
channel.setMethodCallHandler(this);
}
@Override
public void onMethodCall(@NonNull MethodCall call, @NonNull Result result) {
String method = call.method;
if (method.equals("initMQ")) {
initMQ(call,result);
} else if(method.equals("pushToMQVC")){
pushToMeiqiaVC(result);
}else {
result.notImplemented();
}
}
public void initMQ(@NonNull MethodCall call, @NonNull final Result result) {
String appKey = call.argument("appKey");
MQConfig.init(context, appKey, new OnInitCallback() {
@Override
public void onSuccess(String clientId) {
result.success(true);
}
@Override
public void onFailure(int code, String message) {
result.success(false);
}
});
}
public void pushToMeiqiaVC(@NonNull final Result result) {
Intent intent = new MQIntentBuilder(context).build();
context.startActivity(intent);
result.success(true);
}
// func pushToMeiqiaVC(@NonNull MethodCall call, @NonNull Result result) {
// //跳转聊天界面
// let vc = MQChatViewManager.init()
// vc.pushMQChatViewController(in: navigationController())
// result(true);
// }
// func getLocalUnreadeMessages(@NonNull MethodCall call, @NonNull Result result) {
// //获取未读消息数量
//
// if let array = MQManager.getLocalUnreadeMessages(){
// result(array.count);
// }else{
// result(0)
// }
//
// }
@Override
public void onDetachedFromEngine(@NonNull FlutterPluginBinding binding) {
channel.setMethodCallHandler(null);
}
@Override
public void onAttachedToActivity(@NonNull ActivityPluginBinding binding) {
this.context = binding.getActivity();
}
@Override
public void onDetachedFromActivityForConfigChanges() {
}
@Override
public void onReattachedToActivityForConfigChanges(@NonNull ActivityPluginBinding binding) {
}
@Override
public void onDetachedFromActivity() {
}
}
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/lib" isTestSource="false" />
<excludeFolder url="file://$MODULE_DIR$/.dart_tool" />
<excludeFolder url="file://$MODULE_DIR$/.idea" />
<excludeFolder url="file://$MODULE_DIR$/.pub" />
<excludeFolder url="file://$MODULE_DIR$/build" />
<excludeFolder url="file://$MODULE_DIR$/example/.dart_tool" />
<excludeFolder url="file://$MODULE_DIR$/example/.pub" />
<excludeFolder url="file://$MODULE_DIR$/example/build" />
</content>
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="Dart SDK" level="project" />
<orderEntry type="library" name="Flutter Plugins" level="project" />
</component>
</module>
\ No newline at end of file
.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
\ No newline at end of file
#import <Flutter/Flutter.h>
@interface FlutterMeiqiaPlugin : NSObject<FlutterPlugin>
@end
#import "FlutterMeiqiaPlugin.h"
#if __has_include(<flutter_meiqia/flutter_meiqia-Swift.h>)
#import <flutter_meiqia/flutter_meiqia-Swift.h>
#else
// Support project import fallback if the generated compatibility header
// is not copied when this plugin is created as a library.
// https://forums.swift.org/t/swift-static-libraries-dont-copy-generated-objective-c-header/19816
#import "flutter_meiqia-Swift.h"
#endif
@implementation FlutterMeiqiaPlugin
+ (void)registerWithRegistrar:(NSObject<FlutterPluginRegistrar>*)registrar {
[SwiftFlutterMeiqiaPlugin registerWithRegistrar:registrar];
}
@end
import Flutter
import UIKit
import MeiQiaSDK
import Meiqia
public class SwiftFlutterMeiqiaPlugin: NSObject, FlutterPlugin {
public static func register(with registrar: FlutterPluginRegistrar) {
let channel = FlutterMethodChannel(name: "flutter_meiqia", binaryMessenger: registrar.messenger())
let instance = SwiftFlutterMeiqiaPlugin()
registrar.addMethodCallDelegate(instance, channel: channel)
registrar.addApplicationDelegate(instance)
}
public func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult) {
switch call.method {
case "initMQ":
initMQ(call, result: result)
case "startMQ":
startMeiqia(call, result: result)
case "closeMQ":
closeMeiqia(call, result: result)
case "pushToMQVC":
pushToMeiqiaVC(call, result: result)
case "getLocalUnreadeMessagesCount":
getLocalUnreadeMessages(call, result: result)
default:
result(FlutterMethodNotImplemented)
}
}
func initMQ(_ call: FlutterMethodCall,result: @escaping FlutterResult) {
let appKey = (call.arguments as! [String: Any])["appKey"] as! String
MQManager.initWithAppkey(appKey) { (str, err) in
if(err==nil){
result(true)
}else{
result(false)
}
}
}
func startMeiqia(_ call: FlutterMethodCall,result: @escaping FlutterResult) {
//进入前台 打开meiqia服务
MQManager.openMeiqiaService()
result(true);
}
func closeMeiqia(_ call: FlutterMethodCall,result: @escaping FlutterResult) {
//进入后台 关闭美洽服务
MQManager.closeMeiqiaService()
result(true);
}
func pushToMeiqiaVC(_ call: FlutterMethodCall,result: @escaping FlutterResult) {
//跳转聊天界面
let vc = MQChatViewManager.init()
vc.pushMQChatViewController(in: navigationController())
result(true);
}
func getLocalUnreadeMessages(_ call: FlutterMethodCall,result: @escaping FlutterResult) {
//获取未读消息数量
if let array = MQManager.getLocalUnreadeMessages(){
result(array.count);
}else{
result(0)
}
}
func navigationController() -> UINavigationController {
let delegate = UIApplication.shared.delegate as! FlutterAppDelegate
let navigationController = delegate.window?.rootViewController as! UINavigationController
return navigationController;
}
}
extension SwiftFlutterMeiqiaPlugin{
public func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
//上传设备deviceToken
MQManager.registerDeviceToken(deviceToken)
}
}
#
# To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html.
# Run `pod lib lint flutter_meiqia.podspec' to validate before publishing.
#
Pod::Spec.new do |s|
s.name = 'flutter_meiqia'
s.version = '0.0.1'
s.summary = '美恰客服'
s.description = <<-DESC
美恰客服
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.dependency 'Flutter'
s.platform = :ios, '10.0'
s.static_framework = true
s.dependency 'Meiqia', '~> 3.6.7'
# Flutter.framework does not contain a i386 slice.
s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES', 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'i386' }
s.swift_version = '5.0'
end
import 'package:flutter/services.dart';
class FlutterMeiQia {
static const MethodChannel _channel = const MethodChannel('flutter_meiqia');
static Future initMQ(String appKey) async {
var res = await _channel.invokeMethod('initMQ', {'appKey': appKey});
return res;
}
// static Future startMQ() async {
// var res = await _channel.invokeMethod('startMQ');
// return res;
// }
// static Future closeMQ() async {
// var res = await _channel.invokeMethod('closeMQ');
// return res;
// }
static Future pushToMQVC() async {
var res = await _channel.invokeMethod('pushToMQVC');
return res;
}
static Future getLocalUnreadeMessagesCount() async {
var res = await _channel.invokeMethod('getLocalUnreadeMessagesCount');
return res;
}
}
# Generated by pub
# See https://dart.dev/tools/pub/glossary#lockfile
packages:
async:
dependency: transitive
description:
name: async
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.5.0-nullsafety.1"
boolean_selector:
dependency: transitive
description:
name: boolean_selector
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.1.0-nullsafety.1"
characters:
dependency: transitive
description:
name: characters
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.1.0-nullsafety.3"
charcode:
dependency: transitive
description:
name: charcode
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.2.0-nullsafety.1"
clock:
dependency: transitive
description:
name: clock
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.1.0-nullsafety.1"
collection:
dependency: transitive
description:
name: collection
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.15.0-nullsafety.3"
fake_async:
dependency: transitive
description:
name: fake_async
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.2.0-nullsafety.1"
flutter:
dependency: "direct main"
description: flutter
source: sdk
version: "0.0.0"
flutter_test:
dependency: "direct dev"
description: flutter
source: sdk
version: "0.0.0"
matcher:
dependency: transitive
description:
name: matcher
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.12.10-nullsafety.1"
meta:
dependency: transitive
description:
name: meta
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.3.0-nullsafety.3"
path:
dependency: transitive
description:
name: path
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.8.0-nullsafety.1"
sky_engine:
dependency: transitive
description: flutter
source: sdk
version: "0.0.99"
source_span:
dependency: transitive
description:
name: source_span
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.8.0-nullsafety.2"
stack_trace:
dependency: transitive
description:
name: stack_trace
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.10.0-nullsafety.1"
stream_channel:
dependency: transitive
description:
name: stream_channel
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.1.0-nullsafety.1"
string_scanner:
dependency: transitive
description:
name: string_scanner
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.1.0-nullsafety.1"
term_glyph:
dependency: transitive
description:
name: term_glyph
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.2.0-nullsafety.1"
test_api:
dependency: transitive
description:
name: test_api
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.2.19-nullsafety.2"
typed_data:
dependency: transitive
description:
name: typed_data
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.3.0-nullsafety.3"
vector_math:
dependency: transitive
description:
name: vector_math
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.1.0-nullsafety.3"
sdks:
dart: ">=2.10.0-110 <2.11.0"
flutter: ">=1.20.0"
name: flutter_meiqia
description: 美恰客服
version: 0.0.1
author:
homepage:
environment:
sdk: ">=2.7.0 <3.0.0"
flutter: ">=1.20.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.example.flutter_meiqia
pluginClass: FlutterMeiqiaPlugin
ios:
pluginClass: FlutterMeiqiaPlugin
# 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
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:flutter_meiqia/flutter_meiqia.dart';
void main() {
const MethodChannel channel = MethodChannel('flutter_meiqia');
TestWidgetsFlutterBinding.ensureInitialized();
setUp(() {
channel.setMockMethodCallHandler((MethodCall methodCall) async {
return '42';
});
});
tearDown(() {
channel.setMockMethodCallHandler(null);
});
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment