@@ -524,18 +524,23 @@ protected static Class<?> getOpenAppActivity(Context context, boolean fallbackTo
524
524
}
525
525
526
526
protected static Notification .Builder recoverBuilder (Context context , Notification notification ) {
527
- if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .N ) {
528
- Notification .Builder builder = Notification .Builder .recoverBuilder (context , notification );
529
- // extras not recovered, transfer manually
530
- builder .setExtras (notification .extras );
531
- return builder ;
532
- }
533
- else {
534
- return recoverBuilderPreNougat (context , notification );
527
+ try {
528
+ if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .N ) {
529
+ Notification .Builder builder = Notification .Builder .recoverBuilder (context , notification );
530
+ // extras not recovered, transfer manually
531
+ builder .setExtras (notification .extras );
532
+ return builder ;
533
+ }
534
+ } catch (Exception e ) {
535
+ Log .e (TAG_UNITY , "Failed to recover builder for notification!" , e );
536
+ } catch (OutOfMemoryError e ) {
537
+ Log .e (TAG_UNITY , "Failed to recover builder for notification!" , e );
535
538
}
539
+
540
+ return recoverBuilderCustom (context , notification );
536
541
}
537
542
538
- private static Notification .Builder recoverBuilderPreNougat (Context context , Notification notification ) {
543
+ private static Notification .Builder recoverBuilderCustom (Context context , Notification notification ) {
539
544
String channelID = notification .extras .getString (KEY_CHANNEL_ID );
540
545
Notification .Builder builder = UnityNotificationManager .createNotificationBuilder (context , channelID );
541
546
UnityNotificationManager .setNotificationIcon (builder , KEY_SMALL_ICON , notification .extras .getString (KEY_SMALL_ICON ));
0 commit comments