public void ScheduleRepeated()
        {
            var notificationParams = new NotificationParams
            {
                Id             = NotificationIdHandler.GetNotificationId(),
                Delay          = TimeSpan.FromSeconds(5),
                Title          = "Repeated notification",
                Message        = "Message",
                Ticker         = "Ticker",
                Sound          = true,
                Vibrate        = true,
                Vibration      = new[] { 500, 500, 500, 500, 500, 500 },
                Light          = true,
                LightOnMs      = 1000,
                LightOffMs     = 1000,
                LightColor     = Color.magenta,
                SmallIcon      = NotificationIcon.Skull,
                SmallIconColor = new Color(0, 0.5f, 0),
                LargeIcon      = "app_icon",
                ExecuteMode    = NotificationExecuteMode.Exact,
                Repeat         = true,
                RepeatInterval = TimeSpan.FromSeconds(5) // Don't use short intervals as repeated notifications are inexact
            };

            NotificationManager.SendCustom(notificationParams);
        }
        public void ScheduleCustom()
        {
            // TODO: Please note, that receiving callback will not work if your app was sleeping. It will only work if app was opened (not resumed) by clicking the notification.

            var notificationParams = new NotificationParams
            {
                Id             = NotificationIdHandler.GetNotificationId(),
                Delay          = TimeSpan.FromSeconds(5),
                Title          = "Custom notification",
                Message        = "Message",
                Ticker         = "Ticker",
                Sound          = true,
                Vibrate        = true,
                Vibration      = new[] { 500, 500, 500, 500, 500, 500 },
                Light          = true,
                LightOnMs      = 1000,
                LightOffMs     = 1000,
                LightColor     = Color.red,
                SmallIcon      = NotificationIcon.Biohazard,
                SmallIconColor = new Color(0, 0.5f, 0),
                LargeIcon      = "app_icon",
                ExecuteMode    = NotificationExecuteMode.Inexact,
                CallbackData   = "notification created at " + DateTime.Now
            };

            NotificationManager.SendCustom(notificationParams);
        }
Example #3
0
        public void ScheduleRepeated()
        {
            NotificationParams notificationParams = new NotificationParams
            {
                Id        = NotificationIdHandler.GetNotificationId(),
                Delay     = TimeSpan.FromSeconds(5.0),
                Title     = "Repeated notification",
                Message   = "Please rate the asset on the Asset Store!",
                Ticker    = "This is repeated message ticker!",
                Sound     = true,
                Vibrate   = true,
                Vibration = new int[]
                {
                    500,
                    500,
                    500,
                    500,
                    500,
                    500
                },
                Light          = true,
                LightOnMs      = 1000,
                LightOffMs     = 1000,
                LightColor     = Color.magenta,
                SmallIcon      = NotificationIcon.Skull,
                SmallIconColor = new Color(0f, 0.5f, 0f),
                LargeIcon      = "app_icon",
                ExecuteMode    = NotificationExecuteMode.Inexact,
                Repeat         = true,
                RepeatInterval = TimeSpan.FromSeconds(30.0)
            };

            NotificationManager.SendCustom(notificationParams);
        }
Example #4
0
        public void ScheduleCustom()
        {
            NotificationParams notificationParams = new NotificationParams
            {
                Id        = NotificationIdHandler.GetNotificationId(),
                Delay     = TimeSpan.FromSeconds(5.0),
                Title     = "Notification with callback",
                Message   = "Open app and check the checkbox!",
                Ticker    = "Notification with callback",
                Sound     = true,
                Vibrate   = true,
                Vibration = new int[]
                {
                    500,
                    500,
                    500,
                    500,
                    500,
                    500
                },
                Light          = true,
                LightOnMs      = 1000,
                LightOffMs     = 1000,
                LightColor     = Color.red,
                SmallIcon      = NotificationIcon.Sync,
                SmallIconColor = new Color(0f, 0.5f, 0f),
                LargeIcon      = "app_icon",
                ExecuteMode    = NotificationExecuteMode.Inexact,
                CallbackData   = "notification created at " + DateTime.Now
            };

            NotificationManager.SendCustom(notificationParams);
        }
Example #5
0
        public void ScheduleCustom()
        {
            var notificationParams = new NotificationParams
            {
                Id      = NotificationIdHandler.GetNotificationId(),
                Delay   = TimeSpan.FromSeconds(5),
                Title   = "Notification with callback",
                Message = "Open app and check the checkbox!",
                Ticker  = "Notification with callback",
                Sound   = true,
                //CustomSound = "ding", // AAR\res\raw\ding.wav. Please refer to plugin manual to learn how to add custom sounds.
                Vibrate        = true,
                Vibration      = new[] { 500, 500, 500, 500, 500, 500 },
                Light          = true,
                LightOnMs      = 1000,
                LightOffMs     = 1000,
                LightColor     = Color.red,
                SmallIcon      = NotificationIcon.Sync,
                SmallIconColor = new Color(0f, 0.5f, 0f),
                LargeIcon      = "app_icon",
                ExecuteMode    = NotificationExecuteMode.Inexact,
                Importance     = NotificationImportance.Max,
                CallbackData   = "notification created at " + DateTime.Now
            };

            NotificationManager.SendCustom(notificationParams);
        }
Example #6
0
        public void Repeating()
        {
            var isClicked = PlayerPrefsX.GetBool("ClickedRepeating");

            if (isClicked)
            {
                Debug.Log("sending out comps for each");
                repeatingIDList.Clear();
                int compNumber = 0;
                foreach (string comp in complimentStrings.compList)
                {
                    //this gets the index number of each comp;
                    compNumber = complimentStrings.compList.IndexOf(comp);
                    var notificationParams = new NotificationParams {
                        Id = NotificationIdHandler.GetNotificationId(),
                        //adds 1 to each int and then times it by the delay, so each string happens with delay between it;
                        Delay          = TimeSpan.FromSeconds((compNumber + 1) * 18000),
                        Title          = "Hi",
                        Message        = comp,
                        Ticker         = ":)",
                        Sound          = false,
                        Vibrate        = true,
                        Vibration      = new[] { 500, 500, 500, 500, 500, 500 },
                        Light          = true,
                        LightOnMs      = 1000,
                        LightOffMs     = 1000,
                        LightColor     = Color.magenta,
                        SmallIcon      = NotificationIcon.Star,
                        SmallIconColor = new Color(0f, 0.5f, 0f),
                        LargeIcon      = "app_icon",
                        ExecuteMode    = NotificationExecuteMode.Inexact,
                        Repeat         = true,
                        RepeatInterval = TimeSpan.FromSeconds(UnityEngine.Random.Range(180000, 266400))                           // Don't use short intervals as repeated notifications are always inexact
                    };
                    //add these IDs to a list and then turn it into an array,so that we cancel just these Ids later
                    eachBoolID = notificationParams.Id;
                    repeatingIDList.Add(eachBoolID);
                    Debug.Log("adding this id to list" + eachBoolID);
                    int[] repeatingIDArray = repeatingIDList.ToArray();
                    PlayerPrefsX.SetIntArray("RepeatingIDs", repeatingIDArray);
                    NotificationManager.SendCustom(notificationParams);
                }
            }
            if (!isClicked)
            {
                Debug.Log("stopping comps");
                //get the array and turn it into a list, and then for every id cancel it
                int [] repeatingIDArray = PlayerPrefsX.GetIntArray("RepeatingIDs");
                foreach (int id in repeatingIDArray)
                {
                    Debug.Log("cancelling" + id);
                    NotificationManager.Cancel(id);
                    startRepeatingButton.Colour();
                }
                //clears list
                repeatingIDList.Clear();
            }
        }
Example #7
0
        public void ScheduleMultiline()
        {
            NotificationParams notificationParams = new NotificationParams
            {
                Id        = NotificationIdHandler.GetNotificationId(),
                Delay     = TimeSpan.FromSeconds(5.0),
                Title     = "Multiline notification",
                Message   = "Line#1\nLine#2\nLine#3\nLine#4",
                Ticker    = "This is multiline message ticker!",
                Multiline = true
            };

            NotificationManager.SendCustom(notificationParams);
        }
Example #8
0
        public void ScheduleWithChannel()
        {
            NotificationParams notificationParams = new NotificationParams
            {
                Id          = NotificationIdHandler.GetNotificationId(),
                Delay       = TimeSpan.FromSeconds(5.0),
                Title       = "Notification with news channel",
                Message     = "Check the channel in your app settings!",
                Ticker      = "Notification with news channel",
                ChannelId   = "com.company.app.news",
                ChannelName = "News"
            };

            NotificationManager.SendCustom(notificationParams);
        }
Example #9
0
        public void ScheduleGrouped()
        {
            int notificationId = NotificationIdHandler.GetNotificationId();
            NotificationParams notificationParams = new NotificationParams
            {
                Id           = notificationId,
                GroupName    = "Group",
                GroupSummary = "{0} new messages",
                Delay        = TimeSpan.FromSeconds(5.0),
                Title        = "Grouped notification",
                Message      = "Message " + notificationId,
                Ticker       = "Please rate the asset on the Asset Store!"
            };

            NotificationManager.SendCustom(notificationParams);
        }
 public static int SendWithAppIcon(TimeSpan delay, string title, string message, Color smallIconColor, NotificationIcon smallIcon = NotificationIcon.Bell, bool silent = false)
 {
     return(NotificationManager.SendCustom(new NotificationParams
     {
         Id = NotificationIdHandler.GetNotificationId(),
         Delay = delay,
         Title = title,
         Message = message,
         Ticker = message,
         Sound = !silent,
         Vibrate = !silent,
         Light = true,
         SmallIcon = smallIcon,
         SmallIconColor = smallIconColor,
         LargeIcon = "app_icon",
         ExecuteMode = NotificationExecuteMode.Inexact
     }));
 }
Example #11
0
        public static int Send(TimeSpan delay, string title, string message, Color smallIconColor, NotificationIcon smallIcon = 0, bool silent = false)
        {
            NotificationParams notificationParam = new NotificationParams()
            {
                Id             = NotificationIdHandler.GetNotificationId(),
                Delay          = delay,
                Title          = title,
                Message        = message,
                Ticker         = message,
                Sound          = !silent,
                Vibrate        = !silent,
                Light          = true,
                SmallIcon      = smallIcon,
                SmallIconColor = smallIconColor,
                LargeIcon      = string.Empty,
                ExecuteMode    = NotificationExecuteMode.Inexact
            };

            return(NotificationManager.SendCustom(notificationParam));
        }