Example #1
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 #2
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);
        }
        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);
        }
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);
        }
        public static int SendCustom(NotificationParams notificationParams)
        {
            long num = (long)notificationParams.Delay.TotalMilliseconds;

            new AndroidJavaClass("com.hippogames.simpleandroidnotifications.Controller").CallStatic("SetNotification", notificationParams.Id, num, notificationParams.Title, notificationParams.Message, notificationParams.Ticker, notificationParams.Sound ? 1 : 0, notificationParams.Vibrate ? 1 : 0, notificationParams.Light ? 1 : 0, notificationParams.LargeIcon, GetSmallIconName(notificationParams.SmallIcon), ColotToInt(notificationParams.SmallIconColor), "com.unity3d.player.UnityPlayerActivity");
            return(notificationParams.Id);
        }
Example #6
0
        void Start()
        {
            if (!PlayerPrefs.HasKey("Sended"))
            {
                for (int i = 0; i < messages.Length; i++)
                {
                    var notificationParams = new NotificationParams
                    {
                        Id             = UnityEngine.Random.Range(0, int.MaxValue),
                        Delay          = i == 0 ? TimeSpan.FromHours(2) : TimeSpan.FromDays(i),//TimeSpan.FromSeconds(5) : TimeSpan.FromSeconds(i * 10),//
                        Title          = messages[i],
                        Message        = messages[i],
                        Ticker         = "Ticker",
                        Sound          = true,
                        Vibrate        = true,
                        Light          = true,
                        SmallIcon      = NotificationIcon.Heart,
                        SmallIconColor = new Color(0, 0.5f, 0),
                        LargeIcon      = "app_icon"
                    };

                    NotificationManager.SendCustom(notificationParams);
                }
                PlayerPrefs.SetInt("Sended", 1);
            }
        }
Example #7
0
        /// <summary>
        /// Schedule customizable notification.
        /// </summary>
        public static int SendCustom(NotificationParams notificationParams)
        {
            #if UNITY_EDITOR
            Debug.LogWarning("Simple Android Notifications are not supported for current platform. Build and play this scene on android device!");
            #elif UNITY_ANDROID
            var p              = notificationParams;
            var delay          = (long)p.Delay.TotalMilliseconds;
            var repeatInterval = p.Repeat ? (long)p.RepeatInterval.TotalMilliseconds : 0;
            var vibration      = string.Join(",", p.Vibration.Select(i => i.ToString()).ToArray());

            new AndroidJavaClass(FullClassName).CallStatic("SetNotification", p.Id, p.GroupName ?? "", p.GroupSummary ?? "", p.ChannelId, p.ChannelName, delay, Convert.ToInt32(p.Repeat), repeatInterval, p.Title, p.Message, p.Ticker, Convert.ToInt32(p.Multiline),
                                                           Convert.ToInt32(p.Sound), p.CustomSound ?? "", Convert.ToInt32(p.Vibrate), vibration, Convert.ToInt32(p.Light), p.LightOnMs, p.LightOffMs, ColotToInt(p.LightColor), p.LargeIcon ?? "", GetSmallIconName(p.SmallIcon), ColotToInt(p.SmallIconColor), (int)p.ExecuteMode, p.CallbackData, MainActivityClassName);

            NotificationIdHandler.AddScheduledNotificaion(p.Id);
            #elif UNITY_IPHONE
            var notification = new UnityEngine.iOS.LocalNotification
            {
                hasAction = false,
                alertBody = notificationParams.Message,
                fireDate  = DateTime.Now.Add(notificationParams.Delay)
            };

            UnityEngine.iOS.NotificationServices.ScheduleLocalNotification(notification);
            #endif

            return(notificationParams.Id);
        }
        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 #9
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 #10
0
        public static int SendCustom(NotificationParams notificationParams)
        {
            #if UNITY_ANDROID && !UNITY_EDITOR
            var p     = notificationParams;
            var delay = (long)p.Delay.TotalMilliseconds;

            new AndroidJavaClass(FullClassName).CallStatic("SetNotification", p.Id, delay, p.Title, p.Message, p.Ticker,
                                                           p.Sound ? 1 : 0, p.Vibrate ? 1 : 0, p.Light ? 1 : 0, p.LargeIcon, GetSmallIconName(p.SmallIcon), ColotToInt(p.SmallIconColor), MainActivityClassName);
            #endif

            return(notificationParams.Id);
        }
Example #11
0
        public static int SendCustom(NotificationParams notificationParams)
        {
            NotificationParams notificationParam = notificationParams;
            long   totalMilliseconds             = (long)notificationParam.Delay.TotalMilliseconds;
            long   num = (!notificationParam.Repeat ? (long)0 : (long)notificationParam.RepeatInterval.TotalMilliseconds);
            string str = string.Join(",", (
                                         from i in (IEnumerable <int>)notificationParam.Vibration
                                         select i.ToString()).ToArray <string>());

            (new AndroidJavaClass("com.hippogames.simpleandroidnotifications.Controller")).CallStatic("SetNotification", new object[] { notificationParam.Id, notificationParam.GroupName ?? string.Empty, notificationParam.GroupSummary ?? string.Empty, notificationParam.ChannelId, notificationParam.ChannelName, totalMilliseconds, Convert.ToInt32(notificationParam.Repeat), num, notificationParam.Title, notificationParam.Message, notificationParam.Ticker, Convert.ToInt32(notificationParam.Multiline), Convert.ToInt32(notificationParam.Sound), notificationParam.CustomSound ?? string.Empty, Convert.ToInt32(notificationParam.Vibrate), str, Convert.ToInt32(notificationParam.Light), notificationParam.LightOnMs, notificationParam.LightOffMs, NotificationManager.ColotToInt(notificationParam.LightColor), notificationParam.LargeIcon ?? string.Empty, NotificationManager.GetSmallIconName(notificationParam.SmallIcon), NotificationManager.ColotToInt(notificationParam.SmallIconColor), (int)notificationParam.ExecuteMode, notificationParam.CallbackData, "com.blizzard.wowcompanion.CompanionNativeActivity" });
            NotificationIdHandler.AddScheduledNotificaion(notificationParam.Id);
            return(notificationParams.Id);
        }
Example #12
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);
        }
        /// <summary>
        /// Schedule customizable notification.
        /// </summary>
        public static int SendCustom(NotificationParams notificationParams)
        {
            #if UNITY_ANDROID && !UNITY_EDITOR
            var p     = notificationParams;
            var delay = (long)p.Delay.TotalMilliseconds;

            new AndroidJavaClass(FullClassName).CallStatic("SetNotification", p.Id, delay, p.Title, p.Message, p.Ticker,
                                                           p.Sound ? 1 : 0, p.Vibrate ? 1 : 0, p.Light ? 1 : 0, p.LargeIcon, GetSmallIconName(p.SmallIcon), ColotToInt(p.SmallIconColor), MainActivityClassName);
            #else
            Debug.LogWarning("Simple Android Notifications are not supported for current platform. Build and play this scene on android device!");
            #endif

            return(notificationParams.Id);
        }
Example #14
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 #15
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);
        }
 // Creates a Notification params object with the values of a normal notification
 private void NotificationParams(string title, string message)
 {
     this._parameters = new NotificationParams
     {
         Id             = UnityEngine.Random.Range(0, int.MaxValue),
         Delay          = TimeSpan.FromSeconds(3),
         Title          = title,
         Message        = message,
         Ticker         = message,
         Sound          = true,
         Vibrate        = true,
         Light          = true,
         SmallIcon      = NotificationIcon.Message,
         SmallIconColor = new Color(0, 0.29f, 0.6f),
         LargeIcon      = "app_icon"
     };
 }
Example #17
0
        /// <summary>
        /// Schedule customizable notification.
        /// </summary>
        public static int SendCustom(NotificationParams notificationParams)
        {
            #if UNITY_ANDROID && !UNITY_EDITOR
            var p              = notificationParams;
            var delay          = (long)p.Delay.TotalMilliseconds;
            var repeatInterval = p.Repeat ? (long)p.RepeatInterval.TotalMilliseconds : 0;
            var vibration      = string.Join(",", p.Vibration.Select(i => i.ToString()).ToArray());

            new AndroidJavaClass(FullClassName).CallStatic("SetNotification", p.Id, delay, p.Repeat ? 1 : 0, repeatInterval, p.Title, p.Message, p.Ticker,
                                                           p.Sound ? 1 : 0, p.Vibrate ? 1 : 0, vibration, p.Light ? 1 : 0, p.LightOnMs, p.LightOffMs, ColotToInt(p.LightColor), p.LargeIcon, GetSmallIconName(p.SmallIcon), ColotToInt(p.SmallIconColor), (int)p.ExecuteMode, p.CallbackData, MainActivityClassName);

            NotificationIdHandler.AddScheduledNotificaion(p.Id);
            #else
            Debug.LogWarning("Simple Android Notifications are not supported for current platform. Build and play this scene on android device!");
            #endif

            return(notificationParams.Id);
        }
        /// <summary>
        /// Schedule customizable notification.
        /// </summary>
        public static int SendPushCustom(NotificationParams notificationParams)
        {
            #if UNITY_ANDROID && !UNITY_EDITOR
            UserEditor.Getsingleton.EditLog("START AOS LOCAL PUSH");

            var p     = notificationParams;
            var delay = (long)p.Delay.TotalMilliseconds;
            NotificationManager.id = p.Id;

            new AndroidJavaClass(FullClassName).CallStatic("SetNotification", p.Id, delay, p.Title, p.Message, p.Ticker,
                                                           p.Sound ? 1 : 0, p.Vibrate ? 1 : 0, p.Light ? 1 : 0, p.LargeIcon, GetSmallIconName(p.SmallIcon), ColotToInt(p.SmallIconColor), MainActivityClassName);
#elif UNITY_IOS
            //Init_Notification();
            UserEditor.Getsingleton.EditLog("START IOS LOCAL PUSH");

            UnityEngine.iOS.LocalNotification noti = new UnityEngine.iOS.LocalNotification();
            noti.alertAction = notificationParams.Title;
            noti.alertBody   = notificationParams.Message;
            noti.applicationIconBadgeNumber = 0;

            IDictionary userInfo = new Dictionary <string, int>(1);
            userInfo["id"] = notificationParams.Id;
            noti.userInfo  = userInfo;

            noti.soundName = UnityEngine.iOS.LocalNotification.defaultSoundName;
            UserEditor.Getsingleton.EditLog("now : " + TimeManager.Instance.Get_nowTime());
            UserEditor.Getsingleton.EditLog("notificationParams.Delay : " + notificationParams.Delay);

            DateTime addingTime = DateTime.Now.Add(notificationParams.Delay);

            UserEditor.Getsingleton.EditLog("adding : " + addingTime);

            //DateTime a = new DateTime(addingTime.Year,addingTime.Month,addingTime.Hour,addingTime.Minute,addingTime.Second);
            noti.fireDate = DateTime.Now;
            UserEditor.Getsingleton.EditLog("noti.fireDate11 : " + noti.fireDate);
            noti.fireDate = noti.fireDate.Add(notificationParams.Delay);
            UserEditor.Getsingleton.EditLog("noti.fireDate22: " + noti.fireDate);
            UnityEngine.iOS.NotificationServices.ScheduleLocalNotification(noti);
#else
            Debug.LogWarning("Simple Android Notifications are not supported for current platform. Build and play this scene on android device!");
            #endif

            return(notificationParams.Id);
        }
Example #19
0
        public void MakeNotification(string message)
        {
            var notificationParams = new NotificationParams
            {
                Id             = UnityEngine.Random.Range(0, int.MaxValue),
                Delay          = TimeSpan.FromSeconds(3),
                Title          = "Ludo Challenge",
                Message        = message,
                Ticker         = "Ticker",
                Sound          = true,
                Vibrate        = true,
                Light          = true,
                SmallIcon      = NotificationIcon.Star,
                SmallIconColor = new Color(0, 0.5f, 0),
                LargeIcon      = "app_icon"
            };

            NotificationManager.SendCustom(notificationParams);
        }
Example #20
0
        public void welcomeNotification()
        {
            var notificationParams = new NotificationParams
            {
                Id             = UnityEngine.Random.Range(0, int.MaxValue),
                Delay          = TimeSpan.FromSeconds(10),
                Title          = "Seja Bem-Vindo !!",
                Message        = "Cuide do Seu Pet, e Cuide de VocĂȘ !!",
                Ticker         = "Ticker",
                Sound          = true,
                Vibrate        = true,
                Light          = true,
                SmallIcon      = NotificationIcon.Heart,
                SmallIconColor = new Color(0, 0.5f, 0),
                LargeIcon      = "app_icon"
            };

            NotificationManager.SendCustom(notificationParams);
        }
        public void ScheduleCustom()
        {
            var notificationParams = new NotificationParams
            {
                Id             = UnityEngine.Random.Range(0, int.MaxValue),
                Delay          = TimeSpan.FromSeconds(5),
                Title          = "Custom notification",
                Message        = "Message",
                Ticker         = "Ticker",
                Sound          = true,
                Vibrate        = true,
                Light          = true,
                SmallIcon      = NotificationIcon.Heart,
                SmallIconColor = new Color(0, 0.5f, 0),
                LargeIcon      = "app_icon"
            };

            NotificationManager.SendCustom(notificationParams);
        }
Example #22
0
        public void Once()
        //sends one random string at random time
        {
            int randomstring       = (UnityEngine.Random.Range(0, complimentStrings.compList.Count));
            var notificationParams = new NotificationParams {
                Id             = UnityEngine.Random.Range(0, int.MaxValue),
                Delay          = TimeSpan.FromSeconds(UnityEngine.Random.Range(14400, 43200)),
                Title          = "Hi",
                Message        = complimentStrings.compList[randomstring],
                Ticker         = ":)",
                Sound          = true,
                Vibrate        = true,
                Light          = true,
                SmallIcon      = NotificationIcon.Heart,
                SmallIconColor = new Color(0, 0.5f, 0),
                LargeIcon      = "app_icon"
            };

            NotificationManager.SendCustom(notificationParams);
        }
Example #23
0
        public static int SendWithAppIcon(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      = "app_icon",
                ExecuteMode    = NotificationExecuteMode.Inexact
            };

            return(NotificationManager.SendCustom(notificationParam));
        }
    void SetNotification()
    {
        Assets.SimpleAndroidNotifications.NotificationManager.CancelAll();//21,600
        var notificationParams = new Assets.SimpleAndroidNotifications.NotificationParams
        {
            Id             = UnityEngine.Random.Range(0, int.MaxValue),
            Delay          = TimeSpan.FromSeconds(21600),
            Title          = "Apply for jobs",
            Message        = "More job offers has been updated",
            Ticker         = "Ticker",
            Sound          = true,
            Vibrate        = true,
            Light          = true,
            SmallIcon      = Assets.SimpleAndroidNotifications.NotificationIcon.Bell,
            SmallIconColor = new Color(0, 0.5f, 0),
            LargeIcon      = "app_icon"
        };

        Assets.SimpleAndroidNotifications.NotificationManager.SendCustom(notificationParams);
    }
Example #25
0
        public void ScheduleCustom()
        {
            _alarmouENaoTomou = true;

            var notificationParams = new NotificationParams
            {
                Id             = _id,
                Delay          = TimeSpan.FromSeconds(0),
                Title          = "Hora do Medicamento: " + _name,
                Message        = "Cuide do seu Pet Digital",
                Ticker         = "Ticker",
                Sound          = true,
                Vibrate        = true,
                Light          = true,
                SmallIcon      = NotificationIcon.Heart,
                SmallIconColor = new Color(0, 0.5f, 0),
                LargeIcon      = "app_icon"
            };

            NotificationManager.SendCustom(notificationParams);
        }
        public static int SendCustom(NotificationParams notificationParams)
        {
            long   num  = (long)notificationParams.Delay.TotalMilliseconds;
            long   num2 = (!notificationParams.Repeat) ? 0L : ((long)notificationParams.RepeatInterval.TotalMilliseconds);
            string text = string.Join(",", (from i in notificationParams.Vibration
                                            select i.ToString()).ToArray <string>());

            new AndroidJavaClass("com.hippogames.simpleandroidnotifications.Controller").CallStatic("SetNotification", new object[]
            {
                notificationParams.Id,
                notificationParams.GroupName ?? string.Empty,
                notificationParams.GroupSummary ?? string.Empty,
                notificationParams.ChannelId,
                notificationParams.ChannelName,
                num,
                Convert.ToInt32(notificationParams.Repeat),
                num2,
                notificationParams.Title,
                notificationParams.Message,
                notificationParams.Ticker,
                Convert.ToInt32(notificationParams.Multiline),
                Convert.ToInt32(notificationParams.Sound),
                notificationParams.CustomSound ?? string.Empty,
                Convert.ToInt32(notificationParams.Vibrate),
                text,
                Convert.ToInt32(notificationParams.Light),
                notificationParams.LightOnMs,
                notificationParams.LightOffMs,
                NotificationManager.ColotToInt(notificationParams.LightColor),
                notificationParams.LargeIcon ?? string.Empty,
                NotificationManager.GetSmallIconName(notificationParams.SmallIcon),
                NotificationManager.ColotToInt(notificationParams.SmallIconColor),
                (int)notificationParams.ExecuteMode,
                (int)notificationParams.Importance,
                notificationParams.CallbackData,
                "com.google.firebase.MessagingUnityPlayerActivity"
            });
            NotificationIdHandler.AddScheduledNotificaion(notificationParams.Id);
            return(notificationParams.Id);
        }
Example #27
0
        public void OnGUI()
        {
            if (GUILayout.Button("Simple 5 sec", GUILayout.Height(Screen.height * 0.2f), GUILayout.Width(Screen.width)))
            {
                NotificationManager.Send(TimeSpan.FromSeconds(5), "Simple notification", "Customize icon and color", new Color(1, 0.3f, 0.15f));
            }

            if (GUILayout.Button("Normal 5 sec", GUILayout.Height(Screen.height * 0.2f), GUILayout.Width(Screen.width)))
            {
                NotificationManager.SendWithAppIcon(TimeSpan.FromSeconds(5), "Notification", "Notification with app icon", new Color(0, 0.6f, 1), NotificationIcon.Message);
            }

            if (GUILayout.Button("Custom 5 sec", GUILayout.Height(Screen.height * 0.2f), GUILayout.Width(Screen.width)))
            {
                var notificationParams = new NotificationParams
                {
                    Id             = UnityEngine.Random.Range(0, int.MaxValue),
                    Delay          = TimeSpan.FromSeconds(5),
                    Title          = "Custom notification",
                    Message        = "Message",
                    Ticker         = "Ticker",
                    Sound          = true,
                    Vibrate        = true,
                    Light          = true,
                    SmallIcon      = NotificationIcon.Heart,
                    SmallIconColor = new Color(0, 0.5f, 0),
                    LargeIcon      = "app_icon"
                };

                NotificationManager.SendCustom(notificationParams);
            }

            if (GUILayout.Button("Cancel all", GUILayout.Height(Screen.height * 0.2f), GUILayout.Width(Screen.width)))
            {
                NotificationManager.CancelAll();
            }
        }