Skip to content

Commit f485ab0

Browse files
committed
Merge getOreoNotificationChannel into getNotificationChannel
1 parent 295ee8a commit f485ab0

File tree

2 files changed

+4
-15
lines changed

2 files changed

+4
-15
lines changed

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -195,11 +195,12 @@ protected static String getSharedPrefsNameByChannelId(String id)
195195
return String.format("unity_notification_channel_%s", id);
196196
}
197197

198-
// Get a notification channel by id.
199-
// This function will only be called for devices which are low than Android O.
200198
protected static NotificationChannelWrapper getNotificationChannel(Context context, String id) {
201199
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
202-
return UnityNotificationManagerOreo.getOreoNotificationChannel(context, id);
200+
NotificationChannel ch = getNotificationManager(context).getNotificationChannel(id);
201+
if (ch == null)
202+
return null;
203+
return notificationChannelToWrapper(ch);
203204
}
204205

205206
SharedPreferences prefs = context.getSharedPreferences(getSharedPrefsNameByChannelId(id), Context.MODE_PRIVATE);

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

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,6 @@ public UnityNotificationManagerOreo(Context context, Activity activity) {
1313
super(context, activity);
1414
}
1515

16-
protected static NotificationChannelWrapper getOreoNotificationChannel(Context context, String id) {
17-
assert Build.VERSION.SDK_INT >= Build.VERSION_CODES.O;
18-
19-
List<NotificationChannelWrapper> channelList = new ArrayList<NotificationChannelWrapper>();
20-
21-
for (NotificationChannel ch : getNotificationManager(context).getNotificationChannels()) {
22-
if (ch.getId() == id)
23-
return notificationChannelToWrapper(ch);
24-
}
25-
return null;
26-
}
27-
2816
@Override
2917
public void deleteNotificationChannel(String id) {
3018
assert Build.VERSION.SDK_INT >= Build.VERSION_CODES.O;

0 commit comments

Comments
 (0)