Unity-Technologies / com.unity.mobile.notifications

Mobile Notifications Package
https://docs.unity3d.com/Packages/com.unity.mobile.notifications@2.1/manual/index.html
Other
132 stars 42 forks source link

Merge manager classes #197

Closed aurimasc closed 2 years ago

aurimasc commented 2 years ago

Merge UnityNotificationManager and UnityNotificationManagerOreo classes into one. We had two classes where UnityNotificationManager would provide a simulation implementation of channels, while UnityNotificationManagerOreo would override the same methods and implement real channel support. This causes more confusion than is worth, since channel support code is not that big. Also, the current state of UnityNotificationManager where we actually have two instances and some statics is difficult to maintain and is error prone. The intent is to move away from that and two classes are a bit in a way, so another point for merging them.

Additionally move NotificationChannelWrapper and NotificationCallback into the same source file, they are very small, no real gain with that. Lastly, querying channels was a bit optimized to avoid excessive allocations, for example return null when there are no channels and save C# size from doing several expensive JNI calls to figure that out. Added tests to cover those.

Tested on Nokia 7 Plus (10.0) and Samsung Galaxy S7 (7.0) as well as ran channel related tests on both to make sure both Oreo+ and pre-O code paths work.