Skip to content

Commit 4373ef2

Browse files
committed
Move notification id around along with notification
1 parent 72612d9 commit 4373ef2

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

com.unity.mobile.notifications/Runtime/Android/Plugins/com/unity/androidnotifications/UnityNotificationBackgroundThread.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,17 @@
1111

1212
public class UnityNotificationBackgroundThread extends Thread {
1313
private static class ScheduleNotificationTask implements Runnable {
14+
private int notificationId;
1415
private Notification.Builder notificationBuilder;
1516

16-
public ScheduleNotificationTask(Notification.Builder builder) {
17+
public ScheduleNotificationTask(int id, Notification.Builder builder) {
18+
notificationId = id;
1719
notificationBuilder = builder;
1820
}
1921

2022
@Override
2123
public void run() {
22-
UnityNotificationManager.mUnityNotificationManager.performNotificationScheduling(notificationBuilder);
24+
UnityNotificationManager.mUnityNotificationManager.performNotificationScheduling(notificationId, notificationBuilder);
2325
}
2426
}
2527

@@ -33,8 +35,8 @@ public UnityNotificationBackgroundThread() {
3335
enqueueHousekeeping();
3436
}
3537

36-
public void enqueueNotification(Notification.Builder notificationBuilder) {
37-
mTasks.add(new UnityNotificationBackgroundThread.ScheduleNotificationTask(notificationBuilder));
38+
public void enqueueNotification(int id, Notification.Builder notificationBuilder) {
39+
mTasks.add(new UnityNotificationBackgroundThread.ScheduleNotificationTask(id, notificationBuilder));
3840
}
3941

4042
public void enqueueCancelNotification(int id) {

com.unity.mobile.notifications/Runtime/Android/Plugins/com/unity/androidnotifications/UnityNotificationManager.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -260,12 +260,11 @@ public Object[] getNotificationChannels() {
260260
public void scheduleNotification(Notification.Builder notificationBuilder) {
261261
int id = notificationBuilder.getExtras().getInt(KEY_ID, -1);
262262
putScheduledNotification(id);
263-
mBackgroundThread.enqueueNotification(notificationBuilder);
263+
mBackgroundThread.enqueueNotification(id, notificationBuilder);
264264
}
265265

266-
protected void performNotificationScheduling(Notification.Builder notificationBuilder) {
266+
protected void performNotificationScheduling(int id, Notification.Builder notificationBuilder) {
267267
Bundle extras = notificationBuilder.getExtras();
268-
int id = extras.getInt(KEY_ID, -1);
269268
long repeatInterval = extras.getLong(KEY_REPEAT_INTERVAL, -1);
270269
long fireTime = extras.getLong(KEY_FIRE_TIME, -1);
271270
Notification notification = null;

0 commit comments

Comments
 (0)