@@ -243,13 +243,23 @@ static bool SerializeNotificationCustom(AndroidJavaClass utilsClass, AndroidJava
243
243
}
244
244
245
245
static bool SerializeNotificationCustom_v0 ( AndroidJavaClass utilsClass , AndroidJavaObject byteStream , AndroidJavaObject javaNotif )
246
+ {
247
+ return SerializeNotificationCustom_old ( "serializeNotificationCustom_v0" , byteStream , javaNotif ) ;
248
+ }
249
+
250
+ static bool SerializeNotificationCustom_v1 ( AndroidJavaClass utilsClass , AndroidJavaObject byteStream , AndroidJavaObject javaNotif )
251
+ {
252
+ return SerializeNotificationCustom_old ( "serializeNotificationCustom_v1" , byteStream , javaNotif ) ;
253
+ }
254
+
255
+ static bool SerializeNotificationCustom_old ( string method , AndroidJavaObject byteStream , AndroidJavaObject javaNotif )
246
256
{
247
257
using ( var dataStream = new AndroidJavaObject ( "java.io.DataOutputStream" , byteStream ) )
248
258
{
249
259
bool didSerialize ;
250
260
using ( var testUtils = new AndroidJavaClass ( "com.unity.androidnotifications.UnityNotificationTestUtils" ) )
251
261
{
252
- didSerialize = testUtils . CallStatic < bool > ( "serializeNotificationCustom_v0" , javaNotif , dataStream ) ;
262
+ didSerialize = testUtils . CallStatic < bool > ( method , javaNotif , dataStream ) ;
253
263
}
254
264
dataStream . Call ( "close" ) ;
255
265
return didSerialize ;
@@ -598,4 +608,29 @@ public void CanDeserializeCustomSerializedNotification_v0()
598
608
original . ShowInForeground = true ; // v0 did not have this, so should default to true
599
609
CheckNotificationsMatch ( original , deserialized . Notification ) ;
600
610
}
611
+
612
+ [ Test ]
613
+ [ UnityPlatform ( RuntimePlatform . Android ) ]
614
+ public void CanDeserializeCustomSerializedNotification_v1 ( )
615
+ {
616
+ const int notificationId = 255 ;
617
+
618
+ var original = CreateNotificationWithAllParameters ( ) ;
619
+
620
+ AndroidNotificationIntentData deserialized ;
621
+ using ( var builder = AndroidNotificationCenter . CreateNotificationBuilder ( notificationId , original , kChannelId ) )
622
+ {
623
+ // put something to extrax to force completely custom serialization of them
624
+ var bitmap = CreateBitmap ( ) ;
625
+ Assert . IsNotNull ( bitmap ) ;
626
+ var extras = builder . Call < AndroidJavaObject > ( "getExtras" ) ;
627
+ extras . Call ( "putParcelable" , "binder_item" , bitmap ) ;
628
+
629
+ // Serialize like we did in version 0
630
+ deserialized = SerializeDeserializeNotificationWithFunc ( builder , ( u , s , j ) => SerializeNotificationCustom_v1 ( u , s , j ) ) ;
631
+ }
632
+
633
+ Assert . IsNotNull ( deserialized ) ;
634
+ CheckNotificationsMatch ( original , deserialized . Notification ) ;
635
+ }
601
636
}
0 commit comments