Skip to content

Commit 10d8020

Browse files
committed
Adapt PR comments
- Add m_SilentInForeground variable to keep ShowInForeground public variable backward compatible since ShowInForeground should be true by default behaviour. - Value of SHOW_IN_FOREGROUND is namespaced to avoid conflicts.
1 parent bfacfa9 commit 10d8020

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

com.unity.mobile.notifications/Runtime/Android/AndroidNotification.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,13 +180,18 @@ public DateTime CustomTimestamp
180180
/// <summary>
181181
/// Set this notification to be shown when app is in the foreground.
182182
/// </summary>
183-
public bool ShowInForeground { get; set; }
183+
public bool ShowInForeground
184+
{
185+
get => !m_SilentInForeground;
186+
set => m_SilentInForeground = !value;
187+
}
184188

185189
internal bool ShowCustomTimestamp { get; set; }
186190

187191
private Color m_Color;
188192
private TimeSpan m_RepeatInterval;
189193
private DateTime m_CustomTimestamp;
194+
private bool m_SilentInForeground;
190195

191196
/// <summary>
192197
/// Create a notification struct with all optional fields set to default values.
@@ -213,11 +218,11 @@ public AndroidNotification(string title, string text, DateTime fireTime)
213218
GroupAlertBehaviour = GroupAlertBehaviours.GroupAlertAll;
214219
ShowTimestamp = false;
215220
ShowCustomTimestamp = false;
216-
ShowInForeground = true;
217221

218222
m_RepeatInterval = (-1L).ToTimeSpan();
219223
m_Color = new Color(0, 0, 0, 0);
220224
m_CustomTimestamp = (-1L).ToDatetime();
225+
m_SilentInForeground = false;
221226
}
222227

223228
/// <summary>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public class UnityNotificationManager extends BroadcastReceiver {
5656
protected static final String KEY_NOTIFICATION = "unityNotification";
5757
protected static final String KEY_SMALL_ICON = "smallIcon";
5858
protected static final String KEY_CHANNEL_ID = "channelID";
59-
protected static final String SHOW_IN_FOREGROUND = "showInForeground";
59+
protected static final String SHOW_IN_FOREGROUND = "com.unity.showInForeground";
6060

6161
protected static final String NOTIFICATION_CHANNELS_SHARED_PREFS = "UNITY_NOTIFICATIONS";
6262
protected static final String NOTIFICATION_CHANNELS_SHARED_PREFS_KEY = "ChannelIDs";

0 commit comments

Comments
 (0)