|
|
@ -33,6 +33,7 @@ public class JPushPlugin implements MethodCallHandler {
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static String TAG = "| JPUSH | Android | ";
|
|
|
|
public static JPushPlugin instance;
|
|
|
|
public static JPushPlugin instance;
|
|
|
|
static List<Map<String, Object>> openNotificationCache = new ArrayList<>();
|
|
|
|
static List<Map<String, Object>> openNotificationCache = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
|
@ -60,6 +61,7 @@ public class JPushPlugin implements MethodCallHandler {
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void onMethodCall(MethodCall call, Result result) {
|
|
|
|
public void onMethodCall(MethodCall call, Result result) {
|
|
|
|
|
|
|
|
Log.i(TAG,call.method);
|
|
|
|
if (call.method.equals("getPlatformVersion")) {
|
|
|
|
if (call.method.equals("getPlatformVersion")) {
|
|
|
|
result.success("Android " + android.os.Build.VERSION.RELEASE);
|
|
|
|
result.success("Android " + android.os.Build.VERSION.RELEASE);
|
|
|
|
} else if (call.method.equals("setup")) {
|
|
|
|
} else if (call.method.equals("setup")) {
|
|
|
@ -90,12 +92,17 @@ public class JPushPlugin implements MethodCallHandler {
|
|
|
|
getRegistrationID(call, result);
|
|
|
|
getRegistrationID(call, result);
|
|
|
|
} else if (call.method.equals("sendLocalNotification")) {
|
|
|
|
} else if (call.method.equals("sendLocalNotification")) {
|
|
|
|
sendLocalNotification(call, result);
|
|
|
|
sendLocalNotification(call, result);
|
|
|
|
} else {
|
|
|
|
} else if (call.method.equals("setBadge")) {
|
|
|
|
|
|
|
|
setBadge(call, result);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
result.notImplemented();
|
|
|
|
result.notImplemented();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void setup(MethodCall call, Result result) {
|
|
|
|
public void setup(MethodCall call, Result result) {
|
|
|
|
|
|
|
|
Log.d(TAG,"setup :" + call.arguments);
|
|
|
|
|
|
|
|
|
|
|
|
HashMap<String, Object> map = call.arguments();
|
|
|
|
HashMap<String, Object> map = call.arguments();
|
|
|
|
boolean debug = (boolean)map.get("debug");
|
|
|
|
boolean debug = (boolean)map.get("debug");
|
|
|
|
JPushInterface.setDebugMode(debug);
|
|
|
|
JPushInterface.setDebugMode(debug);
|
|
|
@ -112,6 +119,8 @@ public class JPushPlugin implements MethodCallHandler {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void scheduleCache() {
|
|
|
|
public void scheduleCache() {
|
|
|
|
|
|
|
|
Log.d(TAG,"scheduleCache:");
|
|
|
|
|
|
|
|
|
|
|
|
if (dartIsReady) {
|
|
|
|
if (dartIsReady) {
|
|
|
|
// try to shedule notifcation cache
|
|
|
|
// try to shedule notifcation cache
|
|
|
|
for (Map<String, Object> notification: JPushPlugin.openNotificationCache) {
|
|
|
|
for (Map<String, Object> notification: JPushPlugin.openNotificationCache) {
|
|
|
@ -131,6 +140,8 @@ public class JPushPlugin implements MethodCallHandler {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void setTags(MethodCall call, Result result) {
|
|
|
|
public void setTags(MethodCall call, Result result) {
|
|
|
|
|
|
|
|
Log.d(TAG,"setTags:");
|
|
|
|
|
|
|
|
|
|
|
|
List<String>tagList = call.arguments();
|
|
|
|
List<String>tagList = call.arguments();
|
|
|
|
Set<String> tags = new HashSet<>(tagList);
|
|
|
|
Set<String> tags = new HashSet<>(tagList);
|
|
|
|
sequence += 1;
|
|
|
|
sequence += 1;
|
|
|
@ -139,12 +150,16 @@ public class JPushPlugin implements MethodCallHandler {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void cleanTags(MethodCall call, Result result) {
|
|
|
|
public void cleanTags(MethodCall call, Result result) {
|
|
|
|
|
|
|
|
Log.d(TAG,"cleanTags:");
|
|
|
|
|
|
|
|
|
|
|
|
sequence += 1;
|
|
|
|
sequence += 1;
|
|
|
|
callbackMap.put(sequence, result);
|
|
|
|
callbackMap.put(sequence, result);
|
|
|
|
JPushInterface.cleanTags(registrar.context(), sequence);
|
|
|
|
JPushInterface.cleanTags(registrar.context(), sequence);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void addTags(MethodCall call, Result result) {
|
|
|
|
public void addTags(MethodCall call, Result result) {
|
|
|
|
|
|
|
|
Log.d(TAG,"addTags: " + call.arguments);
|
|
|
|
|
|
|
|
|
|
|
|
List<String>tagList = call.arguments();
|
|
|
|
List<String>tagList = call.arguments();
|
|
|
|
Set<String> tags = new HashSet<>(tagList);
|
|
|
|
Set<String> tags = new HashSet<>(tagList);
|
|
|
|
sequence += 1;
|
|
|
|
sequence += 1;
|
|
|
@ -153,6 +168,8 @@ public class JPushPlugin implements MethodCallHandler {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void deleteTags(MethodCall call, Result result) {
|
|
|
|
public void deleteTags(MethodCall call, Result result) {
|
|
|
|
|
|
|
|
Log.d(TAG,"deleteTags: " + call.arguments);
|
|
|
|
|
|
|
|
|
|
|
|
List<String>tagList = call.arguments();
|
|
|
|
List<String>tagList = call.arguments();
|
|
|
|
Set<String> tags = new HashSet<>(tagList);
|
|
|
|
Set<String> tags = new HashSet<>(tagList);
|
|
|
|
sequence += 1;
|
|
|
|
sequence += 1;
|
|
|
@ -161,12 +178,16 @@ public class JPushPlugin implements MethodCallHandler {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void getAllTags(MethodCall call, Result result) {
|
|
|
|
public void getAllTags(MethodCall call, Result result) {
|
|
|
|
|
|
|
|
Log.d(TAG,"getAllTags: ");
|
|
|
|
|
|
|
|
|
|
|
|
sequence += 1;
|
|
|
|
sequence += 1;
|
|
|
|
callbackMap.put(sequence, result);
|
|
|
|
callbackMap.put(sequence, result);
|
|
|
|
JPushInterface.getAllTags(registrar.context(), sequence);
|
|
|
|
JPushInterface.getAllTags(registrar.context(), sequence);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void setAlias(MethodCall call, Result result) {
|
|
|
|
public void setAlias(MethodCall call, Result result) {
|
|
|
|
|
|
|
|
Log.d(TAG,"setAlias: " + call.arguments);
|
|
|
|
|
|
|
|
|
|
|
|
String alias= call.arguments();
|
|
|
|
String alias= call.arguments();
|
|
|
|
sequence += 1;
|
|
|
|
sequence += 1;
|
|
|
|
callbackMap.put(sequence, result);
|
|
|
|
callbackMap.put(sequence, result);
|
|
|
@ -174,6 +195,8 @@ public class JPushPlugin implements MethodCallHandler {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void deleteAlias(MethodCall call, Result result) {
|
|
|
|
public void deleteAlias(MethodCall call, Result result) {
|
|
|
|
|
|
|
|
Log.d(TAG,"deleteAlias:");
|
|
|
|
|
|
|
|
|
|
|
|
String alias= call.arguments();
|
|
|
|
String alias= call.arguments();
|
|
|
|
sequence += 1;
|
|
|
|
sequence += 1;
|
|
|
|
callbackMap.put(sequence, result);
|
|
|
|
callbackMap.put(sequence, result);
|
|
|
@ -181,22 +204,31 @@ public class JPushPlugin implements MethodCallHandler {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void stopPush(MethodCall call, Result result) {
|
|
|
|
public void stopPush(MethodCall call, Result result) {
|
|
|
|
|
|
|
|
Log.d(TAG,"stopPush:");
|
|
|
|
|
|
|
|
|
|
|
|
JPushInterface.stopPush(registrar.context());
|
|
|
|
JPushInterface.stopPush(registrar.context());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void resumePush(MethodCall call, Result result) {
|
|
|
|
public void resumePush(MethodCall call, Result result) {
|
|
|
|
|
|
|
|
Log.d(TAG,"resumePush:");
|
|
|
|
|
|
|
|
|
|
|
|
JPushInterface.resumePush(registrar.context());
|
|
|
|
JPushInterface.resumePush(registrar.context());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void clearAllNotifications(MethodCall call, Result result) {
|
|
|
|
public void clearAllNotifications(MethodCall call, Result result) {
|
|
|
|
|
|
|
|
Log.d(TAG,"clearAllNotifications: ");
|
|
|
|
|
|
|
|
|
|
|
|
JPushInterface.clearAllNotifications(registrar.context());
|
|
|
|
JPushInterface.clearAllNotifications(registrar.context());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void getLaunchAppNotification(MethodCall call, Result result) {
|
|
|
|
public void getLaunchAppNotification(MethodCall call, Result result) {
|
|
|
|
|
|
|
|
Log.d(TAG,"");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void getRegistrationID(MethodCall call, Result result) {
|
|
|
|
public void getRegistrationID(MethodCall call, Result result) {
|
|
|
|
|
|
|
|
Log.d(TAG,"getRegistrationID: ");
|
|
|
|
|
|
|
|
|
|
|
|
String rid = JPushInterface.getRegistrationID(registrar.context());
|
|
|
|
String rid = JPushInterface.getRegistrationID(registrar.context());
|
|
|
|
if (rid == null || rid.isEmpty()) {
|
|
|
|
if (rid == null || rid.isEmpty()) {
|
|
|
@ -208,6 +240,8 @@ public class JPushPlugin implements MethodCallHandler {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void sendLocalNotification(MethodCall call, Result result) {
|
|
|
|
public void sendLocalNotification(MethodCall call, Result result) {
|
|
|
|
|
|
|
|
Log.d(TAG,"sendLocalNotification: " + call.arguments);
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
HashMap<String, Object> map = call.arguments();
|
|
|
|
HashMap<String, Object> map = call.arguments();
|
|
|
|
|
|
|
|
|
|
|
@ -232,6 +266,17 @@ public class JPushPlugin implements MethodCallHandler {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void setBadge(MethodCall call, Result result) {
|
|
|
|
|
|
|
|
Log.d(TAG,"setBadge: " + call.arguments);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
HashMap<String, Object> map = call.arguments();
|
|
|
|
|
|
|
|
Object numObject = map.get("badge");
|
|
|
|
|
|
|
|
if (numObject != null) {
|
|
|
|
|
|
|
|
int num = (int)numObject;
|
|
|
|
|
|
|
|
JPushInterface.setBadgeNumber(registrar.context(),num);
|
|
|
|
|
|
|
|
result.success(true);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 接收自定义消息,通知,通知点击事件等事件的广播
|
|
|
|
* 接收自定义消息,通知,通知点击事件等事件的广播
|
|
|
@ -248,6 +293,7 @@ public class JPushPlugin implements MethodCallHandler {
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void onReceive(Context context, Intent intent) {
|
|
|
|
public void onReceive(Context context, Intent intent) {
|
|
|
|
String action = intent.getAction();
|
|
|
|
String action = intent.getAction();
|
|
|
|
|
|
|
|
|
|
|
|
if (action.equals(JPushInterface.ACTION_REGISTRATION_ID)) {
|
|
|
|
if (action.equals(JPushInterface.ACTION_REGISTRATION_ID)) {
|
|
|
|
String rId = intent.getStringExtra(JPushInterface.EXTRA_REGISTRATION_ID);
|
|
|
|
String rId = intent.getStringExtra(JPushInterface.EXTRA_REGISTRATION_ID);
|
|
|
|
Log.d("JPushPlugin","on get registration");
|
|
|
|
Log.d("JPushPlugin","on get registration");
|
|
|
@ -264,12 +310,16 @@ public class JPushPlugin implements MethodCallHandler {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void handlingMessageReceive(Intent intent) {
|
|
|
|
private void handlingMessageReceive(Intent intent) {
|
|
|
|
|
|
|
|
Log.d(TAG,"handlingMessageReceive " + intent.getAction());
|
|
|
|
|
|
|
|
|
|
|
|
String msg = intent.getStringExtra(JPushInterface.EXTRA_MESSAGE);
|
|
|
|
String msg = intent.getStringExtra(JPushInterface.EXTRA_MESSAGE);
|
|
|
|
Map<String, Object> extras = getNotificationExtras(intent);
|
|
|
|
Map<String, Object> extras = getNotificationExtras(intent);
|
|
|
|
JPushPlugin.transmitMessageReceive(msg, extras);
|
|
|
|
JPushPlugin.transmitMessageReceive(msg, extras);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void handlingNotificationOpen(Context context, Intent intent) {
|
|
|
|
private void handlingNotificationOpen(Context context, Intent intent) {
|
|
|
|
|
|
|
|
Log.d(TAG,"handlingNotificationOpen " + intent.getAction());
|
|
|
|
|
|
|
|
|
|
|
|
String title = intent.getStringExtra(JPushInterface.EXTRA_NOTIFICATION_TITLE);
|
|
|
|
String title = intent.getStringExtra(JPushInterface.EXTRA_NOTIFICATION_TITLE);
|
|
|
|
String alert = intent.getStringExtra(JPushInterface.EXTRA_ALERT);
|
|
|
|
String alert = intent.getStringExtra(JPushInterface.EXTRA_ALERT);
|
|
|
|
Map<String, Object> extras = getNotificationExtras(intent);
|
|
|
|
Map<String, Object> extras = getNotificationExtras(intent);
|
|
|
@ -284,6 +334,8 @@ public class JPushPlugin implements MethodCallHandler {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void handlingNotificationReceive(Context context, Intent intent) {
|
|
|
|
private void handlingNotificationReceive(Context context, Intent intent) {
|
|
|
|
|
|
|
|
Log.d(TAG,"handlingNotificationReceive " + intent.getAction());
|
|
|
|
|
|
|
|
|
|
|
|
String title = intent.getStringExtra(JPushInterface.EXTRA_NOTIFICATION_TITLE);
|
|
|
|
String title = intent.getStringExtra(JPushInterface.EXTRA_NOTIFICATION_TITLE);
|
|
|
|
String alert = intent.getStringExtra(JPushInterface.EXTRA_ALERT);
|
|
|
|
String alert = intent.getStringExtra(JPushInterface.EXTRA_ALERT);
|
|
|
|
Map<String, Object> extras = getNotificationExtras(intent);
|
|
|
|
Map<String, Object> extras = getNotificationExtras(intent);
|
|
|
@ -291,6 +343,8 @@ public class JPushPlugin implements MethodCallHandler {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private Map<String, Object> getNotificationExtras(Intent intent) {
|
|
|
|
private Map<String, Object> getNotificationExtras(Intent intent) {
|
|
|
|
|
|
|
|
Log.d(TAG,"");
|
|
|
|
|
|
|
|
|
|
|
|
Map<String, Object> extrasMap = new HashMap<String, Object>();
|
|
|
|
Map<String, Object> extrasMap = new HashMap<String, Object>();
|
|
|
|
for (String key : intent.getExtras().keySet()) {
|
|
|
|
for (String key : intent.getExtras().keySet()) {
|
|
|
|
if (!IGNORED_EXTRAS_KEYS.contains(key)) {
|
|
|
|
if (!IGNORED_EXTRAS_KEYS.contains(key)) {
|
|
|
@ -307,6 +361,8 @@ public class JPushPlugin implements MethodCallHandler {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void transmitMessageReceive(String message, Map<String, Object> extras) {
|
|
|
|
static void transmitMessageReceive(String message, Map<String, Object> extras) {
|
|
|
|
|
|
|
|
Log.d(TAG,"transmitMessageReceive " + "message=" + message + "extras=" + extras);
|
|
|
|
|
|
|
|
|
|
|
|
if (instance == null) {
|
|
|
|
if (instance == null) {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -318,6 +374,8 @@ public class JPushPlugin implements MethodCallHandler {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void transmitNotificationOpen(String title, String alert, Map<String, Object> extras) {
|
|
|
|
static void transmitNotificationOpen(String title, String alert, Map<String, Object> extras) {
|
|
|
|
|
|
|
|
Log.d(TAG,"transmitNotificationOpen " + "title=" + title + "alert=" + alert + "extras=" + extras);
|
|
|
|
|
|
|
|
|
|
|
|
Map<String, Object> notification= new HashMap<>();
|
|
|
|
Map<String, Object> notification= new HashMap<>();
|
|
|
|
notification.put("title", title);
|
|
|
|
notification.put("title", title);
|
|
|
|
notification.put("alert", alert);
|
|
|
|
notification.put("alert", alert);
|
|
|
@ -338,6 +396,8 @@ public class JPushPlugin implements MethodCallHandler {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void transmitNotificationReceive(String title, String alert, Map<String, Object> extras) {
|
|
|
|
static void transmitNotificationReceive(String title, String alert, Map<String, Object> extras) {
|
|
|
|
|
|
|
|
Log.d(TAG,"transmitNotificationReceive " + "title=" + title + "alert=" + alert + "extras=" + extras);
|
|
|
|
|
|
|
|
|
|
|
|
if (instance == null) {
|
|
|
|
if (instance == null) {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -350,6 +410,8 @@ public class JPushPlugin implements MethodCallHandler {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void transmitReceiveRegistrationId(String rId) {
|
|
|
|
static void transmitReceiveRegistrationId(String rId) {
|
|
|
|
|
|
|
|
Log.d(TAG,"transmitReceiveRegistrationId: " + rId);
|
|
|
|
|
|
|
|
|
|
|
|
if (instance == null) {
|
|
|
|
if (instance == null) {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|