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
        }
예제 #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);
     }
 }
예제 #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
                }
            }
        }
예제 #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
                }
            }
        }