1
1
#if UNITY_ANDROID
2
2
using System ;
3
+ using System . Collections . Generic ;
3
4
using System . IO ;
4
5
using System . Xml ;
5
6
using UnityEditor ;
@@ -68,14 +69,14 @@ private void InjectAndroidManifest(string projectPath)
68
69
69
70
var settings = NotificationSettingsManager . Initialize ( ) . AndroidNotificationSettingsFlat ;
70
71
71
- var useCustomActivity = ( bool ) settings . Find ( i => i . Key == NotificationSettings . AndroidSettings . USE_CUSTOM_ACTIVITY ) . Value ;
72
+ var useCustomActivity = GetSetting < bool > ( settings , NotificationSettings . AndroidSettings . USE_CUSTOM_ACTIVITY ) ;
72
73
if ( useCustomActivity )
73
74
{
74
- var customActivity = ( string ) settings . Find ( i => i . Key == NotificationSettings . AndroidSettings . CUSTOM_ACTIVITY_CLASS ) . Value ;
75
+ var customActivity = GetSetting < string > ( settings , NotificationSettings . AndroidSettings . CUSTOM_ACTIVITY_CLASS ) ;
75
76
AppendAndroidMetadataField ( manifestPath , manifestDoc , "custom_notification_android_activity" , customActivity ) ;
76
77
}
77
78
78
- var enableRescheduleOnRestart = ( bool ) settings . Find ( i => i . Key == NotificationSettings . AndroidSettings . RESCHEDULE_ON_RESTART ) . Value ;
79
+ var enableRescheduleOnRestart = GetSetting < bool > ( settings , NotificationSettings . AndroidSettings . RESCHEDULE_ON_RESTART ) ;
79
80
if ( enableRescheduleOnRestart )
80
81
{
81
82
AppendAndroidMetadataField ( manifestPath , manifestDoc , "reschedule_notifications_on_restart" , "true" ) ;
@@ -85,6 +86,11 @@ private void InjectAndroidManifest(string projectPath)
85
86
manifestDoc . Save ( manifestPath ) ;
86
87
}
87
88
89
+ private static T GetSetting < T > ( List < NotificationSetting > settings , string key )
90
+ {
91
+ return ( T ) settings . Find ( i => i . Key == key ) . Value ;
92
+ }
93
+
88
94
internal static void InjectReceivers ( string manifestPath , XmlDocument manifestXmlDoc )
89
95
{
90
96
const string kNotificationManagerName = "com.unity.androidnotifications.UnityNotificationManager" ;
0 commit comments