iOS:notification plugin

This commit is contained in:
pengfei.zhou
2020-01-09 09:54:08 +08:00
committed by osborn
parent 0087c5bda4
commit 9dabd3b1db
9 changed files with 98 additions and 13 deletions

View File

@@ -42,7 +42,7 @@ dependencies {
implementation 'androidx.appcompat:appcompat:1.1.0'
api 'com.github.penfeizhou:jsc4a:0.1.0'
implementation 'com.squareup.okhttp3:okhttp:4.2.2'
implementation 'com.github.penfeizhou.android.animation:glide-plugin:1.3.1'
implementation 'com.github.penfeizhou.android.animation:glide-plugin:1.3.2'
implementation 'jp.wasabeef:glide-transformations:4.1.0'
implementation 'com.google.code.gson:gson:2.8.6'
implementation "com.google.android.material:material:1.0.0"

View File

@@ -55,8 +55,12 @@ public class NotificationPlugin extends DoricJavaPlugin {
@DoricMethod
public void publish(JSObject args, DoricPromise promise) {
String biz = args.getProperty("biz").asString().value();
String name = args.getProperty("name").asString().value();
JSValue bizValue = args.getProperty("biz");
if (bizValue.isString()) {
String biz = bizValue.asString().value();
name = "__doric__" + biz + "#" + name;
}
String data = null;
JSValue value = args.getProperty("data");
if (value.isString()) {
@@ -67,7 +71,7 @@ public class NotificationPlugin extends DoricJavaPlugin {
if (value.isBoolean()) {
androidSystem = value.asBoolean().value();
}
Intent intent = new Intent("__doric__" + biz + "#" + name);
Intent intent = new Intent(name);
intent.putExtra("__doric_data__", data);
if (androidSystem) {
getDoricContext().getContext().sendBroadcast(intent);
@@ -80,8 +84,12 @@ public class NotificationPlugin extends DoricJavaPlugin {
@DoricMethod
public void subscribe(JSObject args, DoricPromise promise) {
String biz = args.getProperty("biz").asString().value();
String name = args.getProperty("name").asString().value();
JSValue bizValue = args.getProperty("biz");
if (bizValue.isString()) {
String biz = bizValue.asString().value();
name = "__doric__" + biz + "#" + name;
}
final String callbackId = args.getProperty("callback").asString().value();
JSValue value = args.getProperty("androidSystem");
boolean androidSystem = false;
@@ -115,7 +123,7 @@ public class NotificationPlugin extends DoricJavaPlugin {
}
};
IntentFilter intentFilter = new IntentFilter();
intentFilter.addAction("__doric__" + biz + "#" + name);
intentFilter.addAction(name);
if (androidSystem) {
getDoricContext().getContext().registerReceiver(receiver, intentFilter);
systemReceivers.put(callbackId, receiver);