Skip to content

Commit 888a418

Browse files
committed
Serialize showInBackground in basic serialization
1 parent 76d8b25 commit 888a418

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,14 @@
2929
import static com.unity.androidnotifications.UnityNotificationManager.KEY_NOTIFICATION;
3030
import static com.unity.androidnotifications.UnityNotificationManager.KEY_REPEAT_INTERVAL;
3131
import static com.unity.androidnotifications.UnityNotificationManager.KEY_SMALL_ICON;
32+
import static com.unity.androidnotifications.UnityNotificationManager.SHOW_IN_FOREGROUND;
3233
import static com.unity.androidnotifications.UnityNotificationManager.TAG_UNITY;
3334

3435
public class UnityNotificationUtilities {
3536
// magic stands for "Unity Mobile Notifications Notification"
3637
private static final byte[] UNITY_MAGIC_NUMBER = new byte[] { 'U', 'M', 'N', 'N'};
3738
private static final byte[] UNITY_MAGIC_NUMBER_PARCELLED = new byte[] { 'U', 'M', 'N', 'P'};
38-
private static final int NOTIFICATION_SERIALIZATION_VERSION = 0;
39+
private static final int NOTIFICATION_SERIALIZATION_VERSION = 1;
3940
private static final int INTENT_SERIALIZATION_VERSION = 0;
4041

4142
private static final String SAVED_NOTIFICATION_PRIMARY_KEY = "data";
@@ -144,6 +145,7 @@ private static boolean serializeNotificationCustom(Notification notification, Da
144145
out.writeBoolean(notification.extras.getBoolean(Notification.EXTRA_SHOW_CHRONOMETER, false));
145146
out.writeBoolean(showWhen);
146147
serializeString(out, notification.extras.getString(KEY_INTENT_DATA));
148+
out.writeBoolean(notification.extras.getBoolean(SHOW_IN_FOREGROUND, true));
147149
}
148150

149151
serializeString(out, Build.VERSION.SDK_INT < Build.VERSION_CODES.O ? null : notification.getChannelId());
@@ -275,7 +277,7 @@ private static Notification.Builder deserializeNotificationCustom(DataInputStrea
275277
int id = 0;
276278
String title, text, smallIcon, largeIcon, bigText, intentData;
277279
long fireTime, repeatInterval;
278-
boolean usesStopWatch, showWhen;
280+
boolean usesStopWatch, showWhen, showInForeground = true;
279281
Bundle extras = null;
280282
try {
281283
extras = deserializeParcelable(in);
@@ -296,6 +298,8 @@ private static Notification.Builder deserializeNotificationCustom(DataInputStrea
296298
usesStopWatch = in.readBoolean();
297299
showWhen = in.readBoolean();
298300
intentData = deserializeString(in);
301+
if (version > 0)
302+
showInForeground = in.readBoolean();
299303
} else {
300304
title = extras.getString(Notification.EXTRA_TITLE);
301305
text = extras.getString(Notification.EXTRA_TEXT);
@@ -335,6 +339,7 @@ private static Notification.Builder deserializeNotificationCustom(DataInputStrea
335339
builder.getExtras().putLong(KEY_REPEAT_INTERVAL, repeatInterval);
336340
if (intentData != null)
337341
builder.getExtras().putString(KEY_INTENT_DATA, intentData);
342+
builder.getExtras().putBoolean(SHOW_IN_FOREGROUND, showInForeground);
338343
}
339344
if (title != null)
340345
builder.setContentTitle(title);

0 commit comments

Comments
 (0)