diff --git a/android/build.gradle b/android/build.gradle
index adfa6854..ec2d61d3 100644
--- a/android/build.gradle
+++ b/android/build.gradle
@@ -22,6 +22,7 @@ rootProject.allprojects {
}
apply plugin: 'com.android.library'
+apply plugin: 'kotlin-android'
android {
compileSdkVersion 28
@@ -32,9 +33,13 @@ android {
lintOptions {
disable 'InvalidPackage'
}
+ sourceSets {
+ main.java.srcDirs += 'src/main/kotlin'
+ }
}
dependencies {
implementation 'cn.jiguang.sdk:jpush:4.0.9'
implementation 'cn.jiguang.sdk:jcore:2.8.2'
+ implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
\ No newline at end of file
diff --git a/android/src/main/AndroidManifest.xml b/android/src/main/AndroidManifest.xml
index 474d233a..d3a2bcc5 100644
--- a/android/src/main/AndroidManifest.xml
+++ b/android/src/main/AndroidManifest.xml
@@ -1,22 +1,10 @@
+
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -34,5 +22,4 @@
-
diff --git a/android/src/main/java/com/jiguang/jpush/JPushCustomService.java b/android/src/main/java/com/jiguang/jpush/JPushCustomService.java
deleted file mode 100644
index 2fe9d196..00000000
--- a/android/src/main/java/com/jiguang/jpush/JPushCustomService.java
+++ /dev/null
@@ -1,6 +0,0 @@
-package com.jiguang.jpush;
-
-import cn.jpush.android.service.JCommonService;
-
-public class JPushCustomService extends JCommonService {
-}
diff --git a/android/src/main/java/com/jiguang/jpush/JPushEventReceiver.java b/android/src/main/java/com/jiguang/jpush/JPushEventReceiver.java
deleted file mode 100644
index 8e41aa0a..00000000
--- a/android/src/main/java/com/jiguang/jpush/JPushEventReceiver.java
+++ /dev/null
@@ -1,144 +0,0 @@
-package com.jiguang.jpush;
-
-import android.content.Context;
-import android.os.Handler;
-import android.os.Looper;
-import android.util.Log;
-
-import org.json.JSONException;
-import org.json.JSONObject;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import cn.jpush.android.api.JPushInterface;
-import cn.jpush.android.api.JPushMessage;
-import cn.jpush.android.service.JPushMessageReceiver;
-import io.flutter.plugin.common.MethodChannel.Result;
-
-public class JPushEventReceiver extends JPushMessageReceiver {
-
- @Override
- public void onTagOperatorResult(Context context, final JPushMessage jPushMessage) {
- super.onTagOperatorResult(context, jPushMessage);
-
- final JSONObject resultJson = new JSONObject();
-
- final int sequence = jPushMessage.getSequence();
- try {
- resultJson.put("sequence", sequence);
- } catch (JSONException e) {
- e.printStackTrace();
- }
-
- final Result callback = JPushPlugin.instance.callbackMap.get(sequence);//instance.eventCallbackMap.get(sequence);
-
- if (callback == null) {
- Log.i("JPushPlugin", "Unexpected error, callback is null!");
- return;
- }
-
- new Handler(Looper.getMainLooper()).post(new Runnable() {
- @Override
- public void run() {
- if (jPushMessage.getErrorCode() == 0) { // success
- Set tags = jPushMessage.getTags();
- List tagList = new ArrayList<>(tags);
- Map res = new HashMap<>();
- res.put("tags", tagList);
- callback.success(res);
- } else {
- try {
- resultJson.put("code", jPushMessage.getErrorCode());
- } catch (JSONException e) {
- e.printStackTrace();
- }
- callback.error(Integer.toString(jPushMessage.getErrorCode()), "", "");
- }
-
- JPushPlugin.instance.callbackMap.remove(sequence);
- }
- });
-
- }
-
-
-
- @Override
- public void onCheckTagOperatorResult(Context context, final JPushMessage jPushMessage) {
- super.onCheckTagOperatorResult(context, jPushMessage);
-
-
-
- final int sequence = jPushMessage.getSequence();
-
-
- final Result callback = JPushPlugin.instance.callbackMap.get(sequence);
-
- if (callback == null) {
- Log.i("JPushPlugin", "Unexpected error, callback is null!");
- return;
- }
-
- new Handler(Looper.getMainLooper()).post(new Runnable() {
- @Override
- public void run() {
- if (jPushMessage.getErrorCode() == 0) {
- Set tags = jPushMessage.getTags();
- List tagList = new ArrayList<>(tags);
- Map res = new HashMap<>();
- res.put("tags", tagList);
- callback.success(res);
- } else {
-
- callback.error(Integer.toString(jPushMessage.getErrorCode()), "", "");
- }
-
- JPushPlugin.instance.callbackMap.remove(sequence);
- }
- });
- }
-
- @Override
- public void onAliasOperatorResult(Context context, final JPushMessage jPushMessage) {
- super.onAliasOperatorResult(context, jPushMessage);
-
- final int sequence = jPushMessage.getSequence();
-
- final Result callback = JPushPlugin.instance.callbackMap.get(sequence);
-
- if (callback == null) {
- Log.i("JPushPlugin", "Unexpected error, callback is null!");
- return;
- }
-
- new Handler(Looper.getMainLooper()).post(new Runnable() {
- @Override
- public void run() {
- if (jPushMessage.getErrorCode() == 0) { // success
- Map res = new HashMap<>();
- res.put("alias", (jPushMessage.getAlias() == null)? "" : jPushMessage.getAlias());
- callback.success(res);
-
- } else {
- callback.error(Integer.toString(jPushMessage.getErrorCode()), "", "");
- }
-
- JPushPlugin.instance.callbackMap.remove(sequence);
- }
- });
- }
-
- @Override
- public void onNotificationSettingsCheck(Context context, boolean isOn, int source) {
- super.onNotificationSettingsCheck(context, isOn, source);
-
-
- HashMap map = new HashMap();
- map.put("isEnabled",isOn);
- JPushPlugin.instance.runMainThread(map,null,"onReceiveNotificationAuthorization");
- }
-}
diff --git a/android/src/main/java/com/jiguang/jpush/JPushPlugin.java b/android/src/main/java/com/jiguang/jpush/JPushPlugin.java
deleted file mode 100644
index 19c0ef1d..00000000
--- a/android/src/main/java/com/jiguang/jpush/JPushPlugin.java
+++ /dev/null
@@ -1,502 +0,0 @@
-package com.jiguang.jpush;
-
-import android.content.BroadcastReceiver;
-import android.content.Context;
-import android.content.Intent;
-import android.os.Handler;
-import android.os.Looper;
-import android.util.Log;
-
-import org.json.JSONObject;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import cn.jpush.android.api.JPushInterface;
-import cn.jpush.android.data.JPushLocalNotification;
-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;
-
-/**
- * JPushPlugin
- */
-public class JPushPlugin implements FlutterPlugin, MethodCallHandler {
-
-
- private static String TAG = "| JPUSH | Flutter | Android | ";
-
- public static JPushPlugin instance;
-
- static List