public void ScheduleFutureNotification(int seconds)
        {
#if UNITY_ANDROID
            NotificationParams notification = new NotificationParams
            {
                Id             = NotificationIdHandler.GetNotificationId(),
                Ticker         = "Ticker",
                Sound          = true,
                Vibrate        = true,
                Light          = true,
                LargeIcon      = "app_icon",
                SmallIcon      = NotificationIcon.Coin,
                SmallIconColor = new Color(0, 0.5f, 0),
                CallbackData   = "ScheduleFutureNotification", // name of method

                Delay   = TimeSpan.FromSeconds(seconds),
                Title   = androidAppTitle,
                Message = string.Format(scheduledEventNotificationMessage)
            };
            NotificationManager.SendCustom(notification);
#elif UNITY_IOS
            //LocalNotification notification = new LocalNotification
            //{
            //    applicationIconBadgeNumber = 1,
            //    alertBody = string.Format(scheduledEventNotificationMessage, giftName),
            //    fireDate = DateTime.Now.AddSeconds(seconds),
            //    soundName = LocalNotification.defaultSoundName
            //};
            //NotificationServices.ScheduleLocalNotification(notification);
#endif
        }
        // Call by main game OnApplicationPause
        public void ScheduleReturnBackToGameNotification()
        {
#if UNITY_ANDROID
            NotificationParams notification = new NotificationParams
            {
                Id             = NotificationIdHandler.GetNotificationId(),
                Ticker         = "Ticker",
                Sound          = true,
                Vibrate        = true,
                Light          = true,
                LargeIcon      = "app_icon",
                SmallIcon      = NotificationIcon.Heart,
                SmallIconColor = new Color(0, 0.5f, 0),
                CallbackData   = "ScheduleReturnBackToGameNotification", // name of method

                Delay   = TimeSpan.FromSeconds(inactiveLatelyNotificationDelayInSeconds),
                Title   = androidAppTitle,
                Message = inactiveLatelyMessage
            };
            NotificationManager.SendCustom(notification);
#elif UNITY_IOS
            LocalNotification notification = new LocalNotification
            {
                applicationIconBadgeNumber = 1,
                alertBody = inactiveLatelyMessage,
                fireDate  = DateTime.Now.AddSeconds(inactiveLatelyNotificationDelayInSeconds),
                soundName = LocalNotification.defaultSoundName
            };
            NotificationServices.ScheduleLocalNotification(notification);
#endif
        }
Exemplo n.º 3
0
 private void OnApplicationPause(bool isPause)
 {
     try
     {
         if (isPause)
         {
             int                num                = UnityEngine.Random.Range(1, 5);
             string             textByKey          = LocalizationService.Instance.GetTextByKey("localNotification_0" + num + "_title");
             string             textByKey2         = LocalizationService.Instance.GetTextByKey("localNotification_0" + num + "_body");
             NotificationParams notificationParams = new NotificationParams
             {
                 Id             = NotificationIdHandler.GetNotificationId(),
                 Delay          = TimeSpan.FromHours(24.0),
                 Title          = textByKey,
                 Message        = textByKey2,
                 Ticker         = textByKey,
                 Sound          = true,
                 Vibrate        = true,
                 Light          = true,
                 SmallIcon      = NotificationIcon.Bell,
                 SmallIconColor = new Color(0.63f, 0.63f, 0.63f),
                 LargeIcon      = "app_icon",
                 ExecuteMode    = NotificationExecuteMode.Inexact,
                 Importance     = NotificationImportance.Max,
                 Repeat         = true,
                 RepeatInterval = TimeSpan.FromHours(24.0),
                 ChannelId      = "coloring.local",
                 ChannelName    = "Miscellaneous"
             };
             NotificationManager.SendCustom(notificationParams);
         }
         else
         {
             NotificationCallback notificationCallback = NotificationManager.GetNotificationCallback();
             if (notificationCallback != null && notificationCallback.Id != this.lastNotifId)
             {
                 this.lastNotifId = notificationCallback.Id;
                 AppState.LocalNotificationLaunch = true;
                 FMLogger.vCore("local notif app resume");
             }
             NotificationManager.CancelAll();
         }
     }
     catch (Exception ex)
     {
         FMLogger.vCore("NotificationManager resume handler ex. " + ex.Message);
     }
 }
Exemplo n.º 4
0
        // Call by main game OnApplicationPause
        public void ScheduleOneDayNotification()
        {
            string dayNotificationScheduleTime = PlayerPrefs.GetString(Constants.Notifications.DayNotificationScheduleTime, "");

            if (dayNotificationScheduleTime != "")
            {
                DateTime scheduledOneDayNotificationTime = DateTime.ParseExact(dayNotificationScheduleTime, "yyyyMMddHHmmss", CultureInfo.CurrentCulture);
                TimeSpan timeSpan = scheduledOneDayNotificationTime - DateTime.Now;

                if (timeSpan.TotalSeconds > 0)
                {
#if UNITY_ANDROID
                    NotificationParams notification = new NotificationParams
                    {
                        Id             = NotificationIdHandler.GetNotificationId(),
                        Ticker         = "Ticker",
                        Sound          = true,
                        Vibrate        = true,
                        Light          = true,
                        LargeIcon      = "app_icon",
                        SmallIcon      = NotificationIcon.Heart,
                        SmallIconColor = new Color(0, 0.5f, 0),
                        Delay          = TimeSpan.FromSeconds(timeSpan.TotalSeconds),
                        Title          = androidAppTitle,
                        Message        = Random24HourMessage()
                    };
                    NotificationManager.SendCustom(notification);
#elif UNITY_IOS
                    if (notificationsOn)
                    {
                        LocalNotification notification = new LocalNotification
                        {
                            applicationIconBadgeNumber = 1,
                            alertBody = Random24HourMessage(),
                            fireDate  = DateTime.Now.AddSeconds(timeSpan.TotalSeconds),
                            soundName = LocalNotification.defaultSoundName
                        };
                        NotificationServices.ScheduleLocalNotification(notification);
                    }
#endif
                }
            }
        }
Exemplo n.º 5
0
        public void ScheduleFilmReplenishmentNotification(double secondsUntilFull)
        {
            if ((int)secondsUntilFull > 0)
            {
                if (notificationsOn)
                {
                    secondsUntilFull = Mathf.Round((float)BedtimeCheck(secondsUntilFull));
#if UNITY_ANDROID
                    NotificationParams notification = new NotificationParams
                    {
                        Id             = NotificationIdHandler.GetNotificationId(),
                        Ticker         = "Ticker",
                        Sound          = true,
                        Vibrate        = true,
                        Light          = true,
                        LargeIcon      = "app_icon",
                        SmallIcon      = NotificationIcon.Event,
                        SmallIconColor = new Color(0, 0.5f, 0),
                        Delay          = TimeSpan.FromSeconds(secondsUntilFull),
                        Title          = androidAppTitle,
                        Message        = RandomFilmReplenishmentMessage()
                    };
                    NotificationManager.SendCustom(notification);
#elif UNITY_IOS
                    LocalNotification notification = new LocalNotification
                    {
                        applicationIconBadgeNumber = 1,
                        alertBody = RandomFilmReplenishmentMessage(),
                        fireDate  = DateTime.Now.AddSeconds((int)secondsUntilFull),
                        soundName = LocalNotification.defaultSoundName
                    };
                    NotificationServices.ScheduleLocalNotification(notification);
#endif
                }
            }
        }
Exemplo n.º 6
0
        public void GetNotification()
        {
            Debug.Log("Notification");
            string title = "Notificações";

            List <Gallery> options = new List <Gallery>
            {
                new Gallery {
                    text = "Manhã", value = "m"
                },
                new Gallery {
                    text = "Tarde", value = "t"
                },
                new Gallery {
                    text = "Noite", value = "n"
                }
            };

            GetGallery(title, options, (res) =>
            {
                UpdateNotification(res, (hora, minuto, days) =>
                {
                    for (int i = 0; i < days.Length; i++)
                    {
                        Debug.Log("Dia" + i);

                        // Se o dia não estiver marcado, pula para o próximo laço
                        if (days[i] == false)
                        {
                            continue;
                        }

                        // Cria uma data
                        DateTime dt = DateTime.Now;

                        Debug.Log("Hoje é " + dt.ToLongDateString());

                        while ((int)dt.DayOfWeek == i)
                        {
                            dt = dt.AddDays(1);
                            Debug.Log("Próximo :" + dt.DayOfWeek + "-" + i);
                        }

                        Debug.Log("NextFN:" + GetNextWeekday(DayOfWeek.Monday, DateTime.Today));

                        TimeSpan ts = new TimeSpan(hora, minuto, 0);
                        dt          = dt + ts;

                        int nid = res.value.ToCharArray()[0];

                        NotificationIdHandler.RemoveScheduledNotificaion(nid);
                        Debug.Log("Repetir: " + TimeSpan.FromDays(7));
                        NotificationManager.SendCustom(new NotificationParams
                        {
                            Delay          = dt.TimeOfDay,
                            RepeatInterval = TimeSpan.FromDays(7),
                            Repeat         = true,
                            Multiline      = true,
                            Message        = "Hey!\nEstá na hora de medir sua glicemia!\n",
                            Title          = "AGITO",
                            Id             = nid,
                            Ticker         = "Vamos lá!",
                            GroupName      = "AGITO",
                            GroupSummary   = "{0} novas notificações",
                            ChannelId      = "br.pucpr.ppgia.lasin.AGITO." + res.value,
                            ChannelName    = "Glicemia",
                            LargeIcon      = "app_icon",
                            Light          = true,
                            ExecuteMode    = NotificationExecuteMode.ExactAndAllowWhileIdle,
                            SmallIcon      = NotificationIcon.Clock,
                            SmallIconColor = Color.blue,
                            Vibrate        = true,
                            Sound          = true,
                            LightColor     = Color.blue,
                            CallbackData   = "glicemia",
                        });

                        Speak("Feito", () =>
                        {
                            Speak("Vou te lembrar de medir a glicemia às " + hora + ":" + minuto + " nos dias que você definiu!");
                        });
                    }
                });
            });
        }