DEV Community

Cover image for Notification System for android (unity)
MrEngineer
MrEngineer

Posted on • Edited on

Notification System for android (unity)

To create a notification system in Unity for Android, you need the Android notification library, then write a public void function whit DateTime type argument and create a notification channel inside it, then create the notification itself in that function and finally send it to the Android notification center.
Finally, call this function where you want
for example:

public void notificationSchedule(DateTime time)
{

    const string ChannelID = "notification";
   AndroidNotificationChannel notificationChannel = new 
   AndroidNotificationChannel
   {
      Id = ChannelID,
      name = "notification:,
      description = "random description",
      Importance = Importance.Default 
   };
  AndroidNotificationCenter.RegisterNotificationChannel(notificationChannel);
  AndroidNotifition notification = new AndroidNotifition
  {
      Titel = "AnyThing",
      text = "anyThing" ,
      smallIcon = "default",
      largIcon  = "default",
      FireTime = time 
  };
 AndroidNotificationCenter.SendNotification(notification ,ChannelID);
}
Enter fullscreen mode Exit fullscreen mode

unity

notification

android

Top comments (0)