1212import android .content .pm .ApplicationInfo ;
1313import android .os .Build ;
1414import android .os .Bundle ;
15+ import android .util .Log ;
1516import android .util .SparseArray ;
1617
1718import com .facebook .react .bridge .Arguments ;
@@ -108,7 +109,7 @@ public void onCatalystInstanceDestroy() {
108109
109110 @ ReactMethod
110111 public void initPush () {
111- mContext = getCurrentActivity ();
112+ mContext = getReactApplicationContext ();
112113 JPushInterface .init (getReactApplicationContext ());
113114 Logger .toast (mContext , "Init push success" );
114115 Logger .i (TAG , "init Success!" );
@@ -133,7 +134,7 @@ public void getInfo(Callback successCallback) {
133134
134135 @ ReactMethod
135136 public void stopPush () {
136- mContext = getCurrentActivity ();
137+ mContext = getReactApplicationContext ();
137138 JPushInterface .stopPush (getReactApplicationContext ());
138139 Logger .i (TAG , "Stop push" );
139140 Logger .toast (mContext , "Stop push success" );
@@ -148,7 +149,7 @@ public void hasPermission(Callback callback) {
148149
149150 @ ReactMethod
150151 public void resumePush () {
151- mContext = getCurrentActivity ();
152+ mContext = getReactApplicationContext ();
152153 JPushInterface .resumePush (getReactApplicationContext ());
153154 Logger .i (TAG , "Resume push" );
154155 Logger .toast (mContext , "Resume push success" );
@@ -451,7 +452,7 @@ public void clearAllNotifications() {
451452 @ ReactMethod
452453 public void clearNotificationById (int id ) {
453454 try {
454- mContext = getCurrentActivity ();
455+ mContext = getReactApplicationContext ();
455456 JPushInterface .clearNotificationById (mContext , id );
456457 } catch (Exception e ) {
457458 e .printStackTrace ();
@@ -461,7 +462,7 @@ public void clearNotificationById(int id) {
461462 @ ReactMethod
462463 public void setLatestNotificationNumber (int number ) {
463464 try {
464- mContext = getCurrentActivity ();
465+ mContext = getReactApplicationContext ();
465466 JPushInterface .setLatestNotificationNumber (mContext , number );
466467 } catch (Exception e ) {
467468 e .printStackTrace ();
@@ -471,7 +472,7 @@ public void setLatestNotificationNumber(int number) {
471472 @ ReactMethod
472473 public void setPushTime (ReadableMap map ) {
473474 try {
474- mContext = getCurrentActivity ();
475+ mContext = getReactApplicationContext ();
475476 ReadableArray array = map .getArray ("days" );
476477 Set <Integer > days = new HashSet <Integer >();
477478 for (int i =0 ; i < array .size (); i ++) {
@@ -492,7 +493,7 @@ public void setPushTime(ReadableMap map) {
492493 @ ReactMethod
493494 public void setSilenceTime (ReadableMap map ) {
494495 try {
495- mContext = getCurrentActivity ();
496+ mContext = getReactApplicationContext ();
496497 String starTime = map .getString ("startTime" );
497498 String endTime = map .getString ("endTime" );
498499 String [] sTime = starTime .split (":" );
@@ -504,6 +505,30 @@ public void setSilenceTime(ReadableMap map) {
504505 }
505506 }
506507
508+
509+ @ ReactMethod
510+ public void setGeofenceInterval (double interval ) {
511+ Log .i ("tessss" ,interval +"interval" );
512+ try {
513+ mContext = getReactApplicationContext ();
514+ JPushInterface .setGeofenceInterval (mContext , (long )interval );
515+ } catch (Exception e ) {
516+ e .printStackTrace ();
517+ }
518+ }
519+
520+
521+ @ ReactMethod
522+ public void setMaxGeofenceNumber (int maxNumber ) {
523+ Log .i ("tessss" ,maxNumber +"maxNumber" );
524+ try {
525+ mContext = getReactApplicationContext ();
526+ JPushInterface .setMaxGeofenceNumber (mContext , maxNumber );
527+ } catch (Exception e ) {
528+ e .printStackTrace ();
529+ }
530+ }
531+
507532 @ ReactMethod
508533 public void sendLocalNotification (ReadableMap map ) {
509534 try {
@@ -778,7 +803,7 @@ public void finishActivity() {
778803
779804 private boolean hasPermission (String appOpsServiceId ) {
780805
781- Context context = getCurrentActivity (). getApplicationContext ();
806+ Context context = getReactApplicationContext ();
782807 if (Build .VERSION .SDK_INT >= 24 ) {
783808 NotificationManager mNotificationManager = (NotificationManager ) context .getSystemService (
784809 Context .NOTIFICATION_SERVICE );
0 commit comments