- Home /
Question by
duyanfurkan · May 29, 2020 at 08:39 AM ·
androidnotificationnotificationsnotificationservices
Create notification if already there is no notification created
I'm trying to make a notification manager script using unity's mobile notification package. It will create a notification if already there is no notification created. But currently, it's not working. Can you guys help me out? (I target Android devices)
public class NotificationManager : MonoBehaviour
{
private int identifier;
/////////////////////////////// //create notification///////////////////////////////////////////////////
void CreateNotifChannel()
{
var c = new AndroidNotificationChannel()
{
Id = "notifi1",
Name = "Beat Corona",
Importance = Importance.High,
Description ="Reminds the player to play the game",
};
AndroidNotificationCenter.RegisterNotificationChannel(c);
}
public void SendNotification()
{
var notification = new AndroidNotification();
notification.Title = "Hey Doctor";
notification.Text = "Your patient needs your your help.";
notification.FireTime = System.DateTime.Now.AddMinutes(0.1f);
notification.LargeIcon = "icon_1";
notification.SmallIcon = "icon_1";
AndroidNotificationCenter.SendNotification(notification, "notifi1");
identifier = AndroidNotificationCenter.SendNotification(notification, "notifi1");
}
private void Start()
{
if (AndroidNotificationCenter.CheckScheduledNotificationStatus(identifier) != NotificationStatus.Scheduled)
{
SendNotification();
CreateNotifChannel();
}
}
}
Comment
Your answer
Follow this Question
Related Questions
Help with the new Mobile Notification System in Unity 1 Answer
Mobile notifications 0 Answers
Notification did not come after transferring time on the phone 0 Answers
Reading notifications from Unity or knowing if notifications are enabled 0 Answers
How to setup an Android notification at fixed time? 0 Answers