Skip to content

Commit 0ce7967

Browse files
authored
script update v7
1 parent 0fcc2d2 commit 0ce7967

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

NotificationManager.cs

+19-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
using UnityEngine;
22
using System;
3+
using UnityEngine.UI;
4+
using TMPro;
35
#if UNITY_ANDROID
46
using Unity.Notifications.Android;
57
using UnityEngine.Android;
@@ -9,6 +11,10 @@
911

1012
public class NotificationManager : MonoBehaviour
1113
{
14+
public Button SendNotifcationBtn;
15+
public TMP_InputField tittleInputField;
16+
public TMP_InputField messageInputField;
17+
public TMP_InputField timeInputField;
1218
private void Start()
1319
{
1420
#if UNITY_ANDROID
@@ -26,9 +32,20 @@ private void Start()
2632
};
2733

2834
AndroidNotificationCenter.RegisterNotificationChannel(channel);
29-
30-
SendNotification("Test Notification", "This is a test notification", 10);
3135
#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);
3249
}
3350

3451
public void SendNotification(string title, string message, float time)

0 commit comments

Comments
 (0)