diff --git a/app/src/main/java/com/example/cosmosclient/services/CosmosBackgroundService.java b/app/src/main/java/com/example/cosmosclient/services/CosmosBackgroundService.java index f850030..af90275 100644 --- a/app/src/main/java/com/example/cosmosclient/services/CosmosBackgroundService.java +++ b/app/src/main/java/com/example/cosmosclient/services/CosmosBackgroundService.java @@ -263,27 +263,32 @@ } private void sendNotifications(CosmosBackgroundService cosmosBackgroundService, List notifications) { - int notificationId = 1; - //以下はボタンについてだよ - Intent intent = new Intent(cosmosBackgroundService, NotificationDone.class); - //snoozeIntent.setAction(ACTION_NOTIFICATION_OFF); - intent.putExtra(EXTRA_NOTIFICATION_ID, 0); - //以下2行はテスト用。本来はNotificationから取ってくる。 - intent.putExtra("gId", UUID.randomUUID().toString()); - intent.putExtra("rId", "rid2"); - int randamCode = (int)(Math.random()*100000); - PendingIntent pendingIntent = PendingIntent.getBroadcast(cosmosBackgroundService, randamCode, intent, PendingIntent.FLAG_UPDATE_CURRENT); + for (Notification notify: notifications) { -// android.app.Notification.Action action = new android.app.Notification.Action(R.drawable.notification_icon, "ボタンだよ", pendingIntent); - android.app.Notification notification = new android.app.Notification.Builder(cosmosBackgroundService) - .setContentTitle("通知タイトル") - .setContentText("通知ないよう") - .setSmallIcon(R.drawable.icon_no) - .setChannelId("cosmos") + int notificationId = 1; + //以下はボタンについてだよ + Intent intent = new Intent(cosmosBackgroundService, NotificationDone.class); + //snoozeIntent.setAction(ACTION_NOTIFICATION_OFF); + intent.putExtra(EXTRA_NOTIFICATION_ID, 0); + //以下2行はテスト用。本来はNotificationから取ってくる。 + intent.putExtra("gId", notify.getGroup().getgId()); + intent.putExtra("rId", notify.getRequest().getrId()); + int randamCode = (int)(Math.random()*100000); + PendingIntent pendingIntent = PendingIntent.getBroadcast(cosmosBackgroundService, randamCode, intent, PendingIntent.FLAG_UPDATE_CURRENT); + + android.app.Notification.Action action = new android.app.Notification.Action(R.drawable.notification_icon, "ボタンだよ", pendingIntent); + android.app.Notification notification = new android.app.Notification.Builder(cosmosBackgroundService) + .setContentTitle(notify.getRequest().getProduct()) + .setContentText("通知ないよう") + .setSmallIcon(R.drawable.icon_no) + .setChannelId("cosmos") // .setGroup("") -// .addAction(action) - .build(); - notificationManager.notify(notificationId, notification); + .addAction(action) + .build(); + notificationManager.notify(notificationId, notification); + } + + } @Override