|
@@ -128,16 +128,19 @@ public class HolaModule extends ReactContextBaseJavaModule {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@ReactMethod
|
|
@ReactMethod
|
|
|
- public void addLocalPush(String jsonData){
|
|
|
|
|
- if (getCurrentActivity()==null){
|
|
|
|
|
- return;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ public void clearNotification(){
|
|
|
|
|
+ clearClockSchedule();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private void clearClockSchedule(){
|
|
|
|
|
+
|
|
|
|
|
+ AlarmManager alarmManager = (AlarmManager) getCurrentActivity().getSystemService(Context.ALARM_SERVICE);
|
|
|
|
|
|
|
|
//取消历史alarm
|
|
//取消历史alarm
|
|
|
List<PendingIntent> allPendingIntents = new ArrayList<>();
|
|
List<PendingIntent> allPendingIntents = new ArrayList<>();
|
|
|
for (int i = 0; i < 10; i++) {
|
|
for (int i = 0; i < 10; i++) {
|
|
|
int requestCode = i;
|
|
int requestCode = i;
|
|
|
- PendingIntent pendingIntent = PendingIntent.getBroadcast(getCurrentActivity(), requestCode, new Intent(), PendingIntent.FLAG_UPDATE_CURRENT);
|
|
|
|
|
|
|
+ PendingIntent pendingIntent = PendingIntent.getBroadcast(getCurrentActivity(), i, new Intent(getCurrentActivity(),AlarmReceiver.class), PendingIntent.FLAG_UPDATE_CURRENT);
|
|
|
if (pendingIntent != null) {
|
|
if (pendingIntent != null) {
|
|
|
allPendingIntents.add(pendingIntent);
|
|
allPendingIntents.add(pendingIntent);
|
|
|
} else {
|
|
} else {
|
|
@@ -145,11 +148,25 @@ public class HolaModule extends ReactContextBaseJavaModule {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- AlarmManager alarmManager = (AlarmManager) getCurrentActivity().getSystemService(Context.ALARM_SERVICE);
|
|
|
|
|
|
|
+
|
|
|
for (PendingIntent pendingIntent : allPendingIntents) {
|
|
for (PendingIntent pendingIntent : allPendingIntents) {
|
|
|
alarmManager.cancel(pendingIntent);
|
|
alarmManager.cancel(pendingIntent);
|
|
|
|
|
+ pendingIntent.cancel();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @ReactMethod
|
|
|
|
|
+ public void addLocalPush(String jsonData){
|
|
|
|
|
+ if (getCurrentActivity()==null){
|
|
|
|
|
+ return;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ //取消历史alarm
|
|
|
|
|
+ clearClockSchedule();
|
|
|
|
|
+
|
|
|
|
|
+ AlarmManager alarmManager = (AlarmManager) getCurrentActivity().getSystemService(Context.ALARM_SERVICE);
|
|
|
|
|
+
|
|
|
|
|
|
|
|
try {
|
|
try {
|
|
|
JSONArray jsonArray = new JSONArray(jsonData);
|
|
JSONArray jsonArray = new JSONArray(jsonData);
|
|
@@ -173,17 +190,7 @@ public class HolaModule extends ReactContextBaseJavaModule {
|
|
|
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
|
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
|
|
|
|
|
|
|
PendingIntent pendingIntent = PendingIntent.getBroadcast(
|
|
PendingIntent pendingIntent = PendingIntent.getBroadcast(
|
|
|
- getCurrentActivity(), i, intent, android.app.PendingIntent.FLAG_UPDATE_CURRENT);
|
|
|
|
|
-
|
|
|
|
|
-// AlarmManager alarmManager = (AlarmManager) getCurrentActivity().getSystemService(Context.ALARM_SERVICE);
|
|
|
|
|
-
|
|
|
|
|
- AlarmManager.AlarmClockInfo info = alarmManager.getNextAlarmClock();
|
|
|
|
|
- if (info!=null){
|
|
|
|
|
- long t = info.getTriggerTime();
|
|
|
|
|
- PendingIntent pt = info.getShowIntent();
|
|
|
|
|
- String aa = info.toString();
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
|
|
+ getCurrentActivity(), i, intent, PendingIntent.FLAG_UPDATE_CURRENT);
|
|
|
|
|
|
|
|
if (mode.equals("ONCE")){
|
|
if (mode.equals("ONCE")){
|
|
|
long leftMillis = toNearest1000(jsonObject.getLong("once")-System.currentTimeMillis());
|
|
long leftMillis = toNearest1000(jsonObject.getLong("once")-System.currentTimeMillis());
|
|
@@ -310,7 +317,7 @@ public class HolaModule extends ReactContextBaseJavaModule {
|
|
|
stopLocation();
|
|
stopLocation();
|
|
|
}
|
|
}
|
|
|
};
|
|
};
|
|
|
- handler.postDelayed(runnable,30000);
|
|
|
|
|
|
|
+ handler.postDelayed(runnable,18000);
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
}
|