2.3.0 officially only support 2021.3+.
I believe it should work fine with 2023.3, I don’t remember breaking changes. Try putting this version manually to the manifest.json file.
Thank you. The package need a sample project implement the icons for android for notifications using the same code for android and ios. It’s confusing and we can’t find any documentation for implement it.
It’s easy. Add in the NotificationCenter.cs runtime two parameters, one for the smallIcon and other for the largeIcon in the ScheduleNotification function. Inside the function, after the Android platform check add the n.SmallIcon and n.LargeIcon and fine! Unity can add this easy to the package and use the icons…
I write the source for the fix if anyone can update the package…
public static int ScheduleNotification<T>(Notification notification, string category, string smallIcon, string largeIcon, T schedule)
where T : NotificationSchedule
{
CheckInitialized();
#if UNITY_ANDROID
var n = (AndroidNotification)notification;
n.SmallIcon = smallIcon;
n.LargeIcon = largeIcon;
schedule.Schedule(ref n);
if (notification.Identifier.HasValue)
{
AndroidNotificationCenter.SendNotificationWithExplicitID(n, category, notification.Identifier.Value);
return notification.Identifier.Value;
}
else
return AndroidNotificationCenter.SendNotification(n, category);
#else
var n = (iOSNotification)notification;
if (n == null)
throw new ArgumentException("Passed notifiation is empty");
n.CategoryIdentifier = category;
schedule.Schedule(ref n);
iOSNotificationCenter.ScheduleNotification(n);
if (notification.Identifier.HasValue)
return notification.Identifier.Value;
// iOSNotification is class and has auto-generated id set at this point
// for consistency with Android set it back to null, so same Notification can be sent again as new one
int id = int.Parse(n.Identifier, NumberStyles.None, CultureInfo.InvariantCulture);
n.Identifier = null;
return id;
#endif
}
What about the explicit cast that converts the internal notification to a platform specific notification?
var androidNotification = (AndroidNotification)notification.InternalNotification;
androidNotification.SmallIcon = "ic_notification";
We thought the intent was that it should allow us to modify things like SmallIcon. But it seems as this returns a struct instance on Android (on iOS the underlying notification is a class type) so changing anything here has no effect.
The purpose of Unified APIs is to provide not only the API, but also the unified behavior on both platforms. That’s why it doesn’t have API for icons - iOS does not have them.
You can use it to setup common stuff, then cast to AndroidNotification, set icons and send that notification through AndroidNotificationCenter.
I understand that you don’t want to add APIs that are redundant when a platform doesn’t support it. I was more curious about the explicit cast. So if we explicitly cast the platform notification to an AndroidNotification and then make changes on that one to set SmallIcon, then the idea is that you no longer should be able to schedule the notification using the NotificationCenter functions?