File tree Expand file tree Collapse file tree 2 files changed +46
-0
lines changed
android/src/main/java/cn/jiguang/plugins/push Expand file tree Collapse file tree 2 files changed +46
-0
lines changed Original file line number Diff line number Diff line change @@ -539,6 +539,47 @@ public void addLocalNotification(ReadableMap readableMap) {
539539 JSONObject notificationExtraJson = new JSONObject (notificationExtra .toHashMap ());
540540 notification .setExtras (notificationExtraJson .toString ());
541541 }
542+
543+ // 设置BuilderId
544+ if (readableMap .hasKey (JConstants .BUILDER_NAME )) {
545+ try {
546+ String layoutFileName = readableMap .getString (JConstants .BUILDER_NAME );
547+ if (!TextUtils .isEmpty (layoutFileName )) {
548+ // 通过布局文件名获取资源ID
549+ int builderId = reactContext .getResources ().getIdentifier (
550+ layoutFileName ,
551+ "layout" ,
552+ reactContext .getPackageName ()
553+ );
554+ if (builderId != 0 ) {
555+ notification .setBuilderId (builderId );
556+ } else {
557+ JLogger .w ("Layout file not found: " + layoutFileName );
558+ }
559+ }
560+ } catch (Exception e ) {
561+ JLogger .w ("Failed to set BuilderId: " + e .getMessage ());
562+ }
563+ }
564+
565+ // 设置Category
566+ if (readableMap .hasKey (JConstants .CATEGORY )) {
567+ String category = readableMap .getString (JConstants .CATEGORY );
568+ if (!TextUtils .isEmpty (category )) {
569+ notification .setCategory (category );
570+ }
571+ }
572+
573+ // 设置Priority
574+ if (readableMap .hasKey (JConstants .PRIORITY )) {
575+ try {
576+ int priority = readableMap .getInt (JConstants .PRIORITY );
577+ notification .setPriority (priority );
578+ } catch (Exception e ) {
579+ JLogger .w ("Priority must be a number" );
580+ }
581+ }
582+
542583 JPushInterface .addLocalNotification (reactContext , notification );
543584 }
544585
Original file line number Diff line number Diff line change @@ -79,4 +79,9 @@ public class JConstants {
7979 public static final String BSSID = "bssid" ;
8080 public static final String SSID = "ssid" ;
8181 public static final String CELL = "cell" ;
82+
83+ // 本地通知相关常量
84+ public static final String BUILDER_NAME = "builderName" ;
85+ public static final String CATEGORY = "category" ;
86+ public static final String PRIORITY = "priority" ;
8287}
You can’t perform that action at this time.
0 commit comments