1212
1313import com .facebook .react .bridge .Arguments ;
1414import com .facebook .react .bridge .Callback ;
15+ import com .facebook .react .bridge .LifecycleEventListener ;
1516import com .facebook .react .bridge .ReactApplicationContext ;
1617import com .facebook .react .bridge .ReactContextBaseJavaModule ;
1718import com .facebook .react .bridge .ReactMethod ;
3940import cn .jpush .android .data .JPushLocalNotification ;
4041import cn .jpush .android .service .JPushMessageReceiver ;
4142
42- public class JPushModule extends ReactContextBaseJavaModule {
43+ public class JPushModule extends ReactContextBaseJavaModule implements LifecycleEventListener {
4344
4445 private static String TAG = "JPushModule" ;
4546 private Context mContext ;
@@ -62,6 +63,7 @@ public class JPushModule extends ReactContextBaseJavaModule {
6263
6364 public JPushModule (ReactApplicationContext reactContext ) {
6465 super (reactContext );
66+ reactContext .addLifecycleEventListener (this );
6567 }
6668
6769 @ Override
@@ -83,6 +85,7 @@ public void initialize() {
8385 @ Override
8486 public void onCatalystInstanceDestroy () {
8587 super .onCatalystInstanceDestroy ();
88+ Logger .i (TAG , "onCatalystInstanceDestroy" );
8689 mCachedBundle = null ;
8790 mRidBundle = null ;
8891 mConnectCachedBundle = null ;
@@ -93,6 +96,7 @@ public void onCatalystInstanceDestroy() {
9396 mRidEvent = null ;
9497 mConnectEvent = null ;
9598 mGetRidCallback = null ;
99+ mRAC = null ;
96100 }
97101
98102 @ ReactMethod
@@ -511,6 +515,41 @@ public void sendLocalNotification(ReadableMap map) {
511515 }
512516 }
513517
518+ @ ReactMethod
519+ public void removeLocalNotification (int id ) {
520+ try {
521+ Logger .d (TAG , "removeLocalNotification:" +id );
522+ JPushInterface .removeLocalNotification (getReactApplicationContext (), id );
523+ } catch (Exception e ) {
524+ e .printStackTrace ();
525+ }
526+ }
527+ @ ReactMethod
528+ public void clearLocalNotifications () {
529+ try {
530+ Logger .d (TAG , "clearLocalNotifications" );
531+ JPushInterface .clearLocalNotifications (getReactApplicationContext ());
532+ } catch (Exception e ) {
533+ e .printStackTrace ();
534+ }
535+ }
536+
537+ @ Override
538+ public void onHostResume () {
539+ Logger .d (TAG , "onHostResume" );
540+ }
541+
542+ @ Override
543+ public void onHostPause () {
544+ Logger .d (TAG , "onHostPause" );
545+ }
546+
547+ @ Override
548+ public void onHostDestroy () {
549+ Logger .d (TAG , "onHostDestroy" );
550+ mRAC = null ;
551+ }
552+
514553 /**
515554 * 接收自定义消息,通知,通知点击事件等事件的广播
516555 * 文档链接:http://docs.jiguang.cn/client/android_api/
0 commit comments