|
|
@@ -46,12 +46,6 @@ import java.util.Calendar;
|
|
|
import java.util.List;
|
|
|
|
|
|
public class HolaModule extends ReactContextBaseJavaModule {
|
|
|
- private static final String CHANNEL_ID = "REMINDER_FS";
|
|
|
- private static final String CHANNEL_NAME = "Reminders for Fasting and Sleep";
|
|
|
-
|
|
|
- private static final String CHANNEL_ID_ADDITIONAL = "REMINDER_FS_ADDITIONAL";
|
|
|
- private static final String CHANNEL_NAME_ADDITIONAL = "Extra Reminders for Fasting and Sleep";
|
|
|
- private static final String CHANNEL_NAME_SUNRISE = "REMINDER_SUN";
|
|
|
private static final String CHANNEL_DESCRIPTION = "Daily reminder notification ";
|
|
|
|
|
|
private Location gpsLocation;
|
|
|
@@ -188,9 +182,10 @@ public class HolaModule extends ReactContextBaseJavaModule {
|
|
|
String title = jsonObject.getString("title");
|
|
|
String body = jsonObject.getString("body");
|
|
|
String strId = jsonObject.getString("id");
|
|
|
+ String channelId = jsonObject.getString("channel_id");
|
|
|
String categoryId = jsonObject.getString("category_id");
|
|
|
|
|
|
- createNotificationChannel(getCurrentActivity(),categoryId);
|
|
|
+ createNotificationChannel(getCurrentActivity(),channelId);
|
|
|
Intent intent = new Intent(getCurrentActivity(), AlarmReceiver.class);
|
|
|
intent.putExtra("title", title);
|
|
|
intent.putExtra("message", body);
|
|
|
@@ -199,7 +194,7 @@ public class HolaModule extends ReactContextBaseJavaModule {
|
|
|
intent.putExtra("categoryId",categoryId);
|
|
|
intent.putExtra("msg_id",i);
|
|
|
intent.putExtra("mode",mode);
|
|
|
- intent.putExtra("channelID",CHANNEL_ID);
|
|
|
+ intent.putExtra("channelID",channelId);
|
|
|
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
|
|
|
|
|
PendingIntent pendingIntent = PendingIntent.getBroadcast(
|
|
|
@@ -267,7 +262,19 @@ public class HolaModule extends ReactContextBaseJavaModule {
|
|
|
|
|
|
private void createNotificationChannel(Context context,String channelId) {
|
|
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
|
|
- NotificationChannel channel = new NotificationChannel(CHANNEL_ID, CHANNEL_NAME, NotificationManager.IMPORTANCE_HIGH);
|
|
|
+ String channelName = "";
|
|
|
+ switch (channelId) {
|
|
|
+ case "REMINDER_FS":
|
|
|
+ channelName = "Reminders for Fasting and Sleep";
|
|
|
+ break;
|
|
|
+ case "REMINDER_FS_EXTRA":
|
|
|
+ channelName = "Extra Reminders for Fasting and Sleep";
|
|
|
+ break;
|
|
|
+ case "REMINDER_SUN":
|
|
|
+ channelName = "Reminders for Sunrise & Sunset";
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ NotificationChannel channel = new NotificationChannel(channelId, channelName, NotificationManager.IMPORTANCE_HIGH);
|
|
|
// channel.setDescription(CHANNEL_DESCRIPTION);
|
|
|
|
|
|
NotificationManager notificationManager = context.getSystemService(NotificationManager.class);
|