@@ -864,13 +864,18 @@ public static AndroidJavaObject CreateNotificationBuilder(int id, AndroidNotific
864
864
Debug . LogError ( "Failed to schedule notification, it did not contain a valid FireTime" ) ;
865
865
}
866
866
867
+ // NOTE: JNI calls are expensive, so we avoid calls that set something that is also a default
868
+
867
869
var notificationBuilder = s_Jni . NotificationManager . CreateNotificationBuilder ( channelId ) ;
868
870
s_Jni . NotificationManager . SetNotificationIcon ( notificationBuilder , s_Jni . NotificationManager . KEY_SMALL_ICON , notification . SmallIcon ) ;
869
871
if ( ! string . IsNullOrEmpty ( notification . LargeIcon ) )
870
872
s_Jni . NotificationManager . SetNotificationIcon ( notificationBuilder , s_Jni . NotificationManager . KEY_LARGE_ICON , notification . LargeIcon ) ;
871
- s_Jni . NotificationBuilder . SetContentTitle ( notificationBuilder , notification . Title ) ;
872
- s_Jni . NotificationBuilder . SetContentText ( notificationBuilder , notification . Text ) ;
873
- s_Jni . NotificationBuilder . SetAutoCancel ( notificationBuilder , notification . ShouldAutoCancel ) ;
873
+ if ( ! string . IsNullOrEmpty ( notification . Title ) )
874
+ s_Jni . NotificationBuilder . SetContentTitle ( notificationBuilder , notification . Title ) ;
875
+ if ( ! string . IsNullOrEmpty ( notification . Text ) )
876
+ s_Jni . NotificationBuilder . SetContentText ( notificationBuilder , notification . Text ) ;
877
+ if ( notification . ShouldAutoCancel )
878
+ s_Jni . NotificationBuilder . SetAutoCancel ( notificationBuilder , notification . ShouldAutoCancel ) ;
874
879
if ( notification . Number >= 0 )
875
880
s_Jni . NotificationBuilder . SetNumber ( notificationBuilder , notification . Number ) ;
876
881
if ( notification . Style == NotificationStyle . BigTextStyle )
@@ -889,12 +894,15 @@ public static AndroidJavaObject CreateNotificationBuilder(int id, AndroidNotific
889
894
s_Jni . NotificationBuilder . SetGroupSummary ( notificationBuilder , notification . GroupSummary ) ;
890
895
if ( ! string . IsNullOrEmpty ( notification . SortKey ) )
891
896
s_Jni . NotificationBuilder . SetSortKey ( notificationBuilder , notification . SortKey ) ;
892
- s_Jni . NotificationBuilder . SetShowWhen ( notificationBuilder , notification . ShowTimestamp ) ;
897
+ if ( notification . ShowTimestamp )
898
+ s_Jni . NotificationBuilder . SetShowWhen ( notificationBuilder , notification . ShowTimestamp ) ;
893
899
int color = notification . Color . ToInt ( ) ;
894
900
if ( color != 0 )
895
901
s_Jni . NotificationManager . SetNotificationColor ( notificationBuilder , color ) ;
896
- s_Jni . NotificationManager . SetNotificationUsesChronometer ( notificationBuilder , notification . UsesStopwatch ) ;
897
- s_Jni . NotificationManager . SetNotificationGroupAlertBehavior ( notificationBuilder , ( int ) notification . GroupAlertBehaviour ) ;
902
+ if ( notification . UsesStopwatch )
903
+ s_Jni . NotificationManager . SetNotificationUsesChronometer ( notificationBuilder , notification . UsesStopwatch ) ;
904
+ if ( notification . GroupAlertBehaviour != GroupAlertBehaviours . GroupAlertAll ) // All is default value
905
+ s_Jni . NotificationManager . SetNotificationGroupAlertBehavior ( notificationBuilder , ( int ) notification . GroupAlertBehaviour ) ;
898
906
899
907
using ( var extras = s_Jni . NotificationBuilder . GetExtras ( notificationBuilder ) )
900
908
{
0 commit comments