File tree 1 file changed +19
-2
lines changed
1 file changed +19
-2
lines changed Original file line number Diff line number Diff line change 1
1
using UnityEngine ;
2
2
using System ;
3
+ using UnityEngine . UI ;
4
+ using TMPro ;
3
5
#if UNITY_ANDROID
4
6
using Unity . Notifications . Android ;
5
7
using UnityEngine . Android ;
9
11
10
12
public class NotificationManager : MonoBehaviour
11
13
{
14
+ public Button SendNotifcationBtn ;
15
+ public TMP_InputField tittleInputField ;
16
+ public TMP_InputField messageInputField ;
17
+ public TMP_InputField timeInputField ;
12
18
private void Start ( )
13
19
{
14
20
#if UNITY_ANDROID
@@ -26,9 +32,20 @@ private void Start()
26
32
} ;
27
33
28
34
AndroidNotificationCenter . RegisterNotificationChannel ( channel ) ;
29
-
30
- SendNotification ( "Test Notification" , "This is a test notification" , 10 ) ;
31
35
#endif
36
+ SendNotifcationBtn . onClick . AddListener ( OnSendNotication ) ;
37
+ //SendNotification("Test Notification", "This is a test notification", 10);
38
+ }
39
+
40
+ public void OnSendNotication ( )
41
+ {
42
+ if ( string . IsNullOrEmpty ( timeInputField . text ) ) return ;
43
+
44
+ float time = float . Parse ( timeInputField . text ) ;
45
+ string title = ( string . IsNullOrEmpty ( tittleInputField . text ) ) ? "Test Notification" : tittleInputField . text ;
46
+ string message = ( string . IsNullOrEmpty ( messageInputField . text ) ) ? $ "Notifications in { time } minutes" : messageInputField . text ;
47
+
48
+ SendNotification ( title , message , time ) ;
32
49
}
33
50
34
51
public void SendNotification ( string title , string message , float time )
You can’t perform that action at this time.
0 commit comments