void OnGUI()
    {
        //Color is supported only in Android >= 5.0

        if (GUILayout.Button("5 SECONDS", GUILayout.Height(Screen.height * 0.2f)))
        {
            LocalNotification.SendNotification(1, 5, "Title", "Long message text", new Color32(0xff, 0x44, 0x44, 255));
        }

        if (GUILayout.Button("5 SECONDS BIG ICON", GUILayout.Height(Screen.height * 0.2f)))
        {
            LocalNotification.SendNotification(2, 5, "Title", "Long message text with big icon", new Color32(0xff, 0x44, 0x44, 255), true, true, true, "app_icon");
        }

        if (GUILayout.Button("EVERY 5 SECONDS", GUILayout.Height(Screen.height * 0.2f)))
        {
            LocalNotification.SendRepeatingNotification(3, 5, 5, "Title", "Long message text", new Color32(0xff, 0x44, 0x44, 255));
        }

        if (GUILayout.Button("STOP", GUILayout.Height(Screen.height * 0.2f)))
        {
            LocalNotification.CancelNotification(1);
            LocalNotification.CancelNotification(2);
            LocalNotification.CancelNotification(3);
        }
    }
Пример #2
0
    void OnApplicationPause(bool pauseStatus)
    {
        if (pauseStatus)
        {
            dataCollected = false;
            if (lifes < maxLifes)
            {
                int totalSecondsRemaining = (minutesRemaining * 60) + Convert.ToInt32(secondsCount) - 60;
                Debug.Log("Seconds Remaining: " + totalSecondsRemaining);

                LocalNotification.CancelNotification(1);
                LocalNotification.SendNotification(1, totalSecondsRemaining, "Kitten Dice", "Your mana is full!!", new Color32(0xff, 0x44, 0x44, 255));
            }

            Storage.SaveLifes(lifes);
            Storage.SaveDateLastConnection();
            Storage.SaveSecondsPassed(Convert.ToInt32(secondsCount));
        }
        else
        {
            if (!dataCollected)
            {
                GetLifeDta();
                dataCollected = true;
            }
        }
    }
Пример #3
0
 void CancelAllNotifications()
 {
     for (int i = 0; i < (int)NotificationTypes.numberOfNotifications; i++)
     {
         LocalNotification.CancelNotification(i);
     }
 }
    void Start()
    {
        LocalNotification.CancelNotification(1);
        System.DateTime datetime   = System.DateTime.Today;
        int             today      = (int)datetime.DayOfWeek;
        int             dateRemind = 0;

        dateRemind = today + minDate;
        dateRemind = minDate + CountToDate(dateRemind);
        timeDelay  = dateRemind * 24 * 60 * 60 + SecondOnDate(dateRemind - 1);
        print("=====\nRimind after: " + dateRemind + " days count down: " + timeDelay + " secs\n======");
#if !UNITY_EDITOR
        string titleNotification   = AllLanguages.notifiTitle[Modules.indexLanguage];
        string contentNotification = AllLanguages.notifiContent[Modules.indexLanguage];
#endif
#if UNITY_IOS && !UNITY_EDITOR
        IOSNotification.RegisterForNotif();
        IOSNotification.CancelNotifications();
        IOSNotification.ScheduleNotification(timeDelay, loopRemind, titleNotification, contentNotification);
#elif UNITY_ANDROID && !UNITY_EDITOR
        if (loopRemind)
        {
            LocalNotification.SendRepeatingNotification(1, timeDelay, timeDelay, titleNotification, contentNotification, new Color32(0xff, 0x44, 0x44, 255), true, true, true, "app_icon");
        }
        else
        {
            LocalNotification.SendNotification(1, timeDelay, titleNotification, contentNotification, new Color32(0xff, 0x44, 0x44, 255), true, true, true, "app_icon");
        }
#endif
    }
Пример #5
0
        public void SetNextFreeTime()
        {
            Debug.Log("Next free turn");

            // Reset the remaining time values
            _timerRemainingHours   = TimerMaxHours;
            _timerRemainingMinutes = TimerMaxMinutes;
            _timerRemainingSeconds = TimerMaxSeconds;

            // Get last free turn time value from storage
            // We can't save long int to PlayerPrefs so store this value as string and convert to long
            _nextFreeTurnTime = new DateTime(Convert.ToInt64(PlayerPrefs.GetString(LAST_FREE_TURN_TIME_NAME, DateTime.Now.Ticks.ToString())))
                                .AddHours(TimerMaxHours)
                                .AddMinutes(TimerMaxMinutes)
                                .AddSeconds(TimerMaxSeconds);

            _isFreeTurnAvailable = false;

            int miliSeconds = (TimerMaxHours * 3600000) + (TimerMaxMinutes * 60000) + (TimerMaxSeconds * 1000);


            LocalNotification.CancelNotification(1);

            if (PlayerPrefs.GetInt(StaticStrings.NotificationsKey, 0) == 0)
            {
                Debug.Log("Start notification");
                LocalNotification.SendNotification(1, miliSeconds, StaticStrings.notificationTitle, StaticStrings.notificationMessage, new Color32(0xff, 0x44, 0x44, 255), true, true, true, "app_icon");
            }
            else
            {
                Debug.Log("Notification disabled");
            }
        }
Пример #6
0
    void CheckSavedSettings()
    {
        if (PlayerPrefs.GetInt("MusicOn") == 1)
        {
            musicToggle.isOn = true;
        }
        else
        {
            musicToggle.isOn = false;
        }

        if (guiEvent != null)
        {
            guiEvent(MUSIC_EVENT);
        }

        if (PlayerPrefs.GetInt("EffectsOn") == 1)
        {
            effectsToggle.isOn = true;
        }
        else
        {
            effectsToggle.isOn = false;
        }

        if (guiEvent != null)
        {
            guiEvent(SOUND_EFFECTS_EVENT);
        }

        if (PlayerPrefs.GetInt("BabyMode") == 1)
        {
            babymodeToggle.isOn = true;
            chupeta.SetActive(true);
            BABY_MODE = true;
        }
        else
        {
            babymodeToggle.isOn = false;
            BABY_MODE           = false;
            chupeta.SetActive(false);
        }

        if (guiEvent != null)
        {
            guiEvent(BABY_EVENT);
        }

        if (PlayerPrefs.GetInt("Notifications") == 1)
        {
            notificationsToggle.isOn = true;
            LocalNotification.SendRepeatingNotification(1, 172800, 172800, "Message from Spidy:", "I could really eat one bug or two", new Color32(0xff, 0xe1, 0x1b, 255), false, false, true, "app_icon");
        }
        else
        {
            notificationsToggle.isOn = false;
            LocalNotification.CancelNotification(1);
        }
    }
Пример #7
0
    void OnDestroy()
    {
        dataCollected = false;
        if (lifes < maxLifes)
        {
            int totalSecondsRemaining = (minutesRemaining * 60) + Convert.ToInt32(secondsCount) - 60;
            //Debug.Log("Seconds Remaining: " + totalSecondsRemaining);

            LocalNotification.CancelNotification(1);
            LocalNotification.SendNotification(1, totalSecondsRemaining, "Kitten Dice", "Your mana is full!!", new Color32(0xff, 0x44, 0x44, 255));
        }

        Storage.SaveLifes(lifes);
        Storage.SaveDateLastConnection();
        Storage.SaveSecondsPassed(Convert.ToInt32(secondsCount));
    }
Пример #8
0
    void OnGUI()
    {
        //Color is supported only in Android >= 5.0
        GUI.enabled = sleepUntil < Time.time;

        if (GUILayout.Button("5 SECONDS", GUILayout.Height(Screen.height * HEIGHT_PORTION)))
        {
            LocalNotification.SendNotification(1, 5, "Title", "Long message text", new Color32(0xff, 0x44, 0x44, 255));
            sleepUntil = Time.time + 5;
        }

        if (GUILayout.Button("5 SECONDS BIG ICON", GUILayout.Height(Screen.height * HEIGHT_PORTION)))
        {
            LocalNotification.SendNotification(1, 5, "Title", "Long message text with big icon", new Color32(0xff, 0x44, 0x44, 255), true, true, true, "app_icon");
            sleepUntil = Time.time + 5;
        }

        if (GUILayout.Button("5 SECONDS BIG ICON , CUSTOM ACTION", GUILayout.Height(Screen.height * HEIGHT_PORTION)))
        {
            LocalNotification.SendNotification(1, 5, "Title", "Long message text with big icon", new Color32(0xff, 0x44, 0x44, 255), true, false, true,
                                               "app_icon", LocalNotification.NotificationExecuteMode.Inexact, "http://www.google.com");
            sleepUntil = Time.time + 5;
        }

        if (GUILayout.Button("EVERY 5 SECONDS", GUILayout.Height(Screen.height * HEIGHT_PORTION)))
        {
            LocalNotification.SendRepeatingNotification(1, 5, 5, "Title", "Long message text", new Color32(0xff, 0x44, 0x44, 255));
            sleepUntil = Time.time + 99999;
        }

        if (GUILayout.Button("10 SECONDS EXACT", GUILayout.Height(Screen.height * HEIGHT_PORTION)))
        {
            LocalNotification.SendNotification(1, 10, "Title", "Long exact message text", new Color32(0xff, 0x44, 0x44, 255), executeMode: LocalNotification.NotificationExecuteMode.ExactAndAllowWhileIdle);
            sleepUntil = Time.time + 10;
        }

        GUI.enabled = true;

        if (GUILayout.Button("STOP", GUILayout.Height(Screen.height * HEIGHT_PORTION)))
        {
            LocalNotification.CancelNotification(1);
            sleepUntil = 0;
        }
    }
Пример #9
0
    private void GetLifeDta()
    {
        LocalNotification.CancelNotification(1);

        languageManager = FindObjectOfType <LanguageManager>();

        DateTime lastCon    = Storage.GetDateLastConnection();
        TimeSpan timePassed = DateTime.Now - lastCon;

        //Storage.SaveLifes(0);
        lifes             = Storage.GetLifes();
        textLifes         = transform.GetChild(0).GetChild(0).GetComponent <Text>();
        textTimeRemaining = transform.GetChild(0).GetChild(1).GetComponent <Text>();

        minutesRemaining  = (maxLifes - lifes) * minutesForLife;
        minutesRemaining -= Convert.ToInt32(timePassed.TotalMinutes);

        if (minutesRemaining <= 0)
        {
            minutesRemaining = 0;
        }

        lifes = maxLifes - (minutesRemaining / minutesForLife);

        if (lifes < maxLifes)
        {
            double decimalPart         = timePassed.TotalMinutes - Convert.ToDouble(timePassed.TotalMinutes.ToString().Split('.')[0]);
            double secondsPassedDouble = decimalPart * 60;
            int    secondsPassed       = Convert.ToInt32(secondsPassedDouble.ToString().Split('.')[0]);

            //Debug.Log("seconds: " + secondsPassed);

            secondsCount = Storage.GetSecondsPassed() - secondsPassed;
        }
        else
        {
            secondsCount = 59;
        }

        textLifes.text         = "x" + lifes;
        textTimeRemaining.text = languageManager.GetString("full");
    }
Пример #10
0
    void OnGUI()
    {
        GUI.enabled = sleepUntil < Time.time;

        if (GUILayout.Button("EM 5 SEGUNDOS", GUILayout.Height(Screen.height * 0.2f)))
        {
            LocalNotification.SendNotification(1, 5, "TITULO: 5s", "coloque a msg aqui", new Color32(0xff, 0x44, 0x44, 255));
            sleepUntil = Time.time + 5;
        }

        if (GUILayout.Button("EM 5 SEGUNDOS COM ICON", GUILayout.Height(Screen.height * 0.2f)))
        {
            LocalNotification.SendNotification(1, 5, "TITULO: 5S ICON", "mensagem com icone", new Color32(0xff, 0x44, 0x44, 255), true, true, true, "app_icon");
            sleepUntil = Time.time + 5;
        }

        if (GUILayout.Button("A CADA 5 SEGUNDOS", GUILayout.Height(Screen.height * 0.2f)))
        {
            LocalNotification.SendRepeatingNotification(1, 5, 5, "TITULO de 5 em 5", "msg de 5 em 5", new Color32(0xff, 0x44, 0x44, 255));
            sleepUntil = Time.time + 99999;
        }

        if (GUILayout.Button("EM EXATOS 10 SEGUNDOS", GUILayout.Height(Screen.height * 0.2f)))
        {
            LocalNotification.SendNotification(1, 10, "TITULO: EXATO 10", "mensagem enviada em 10s", new Color32(0xff, 0x44, 0x44, 255), executeMode: LocalNotification.NotificationExecuteMode.ExactAndAllowWhileIdle);
            sleepUntil = Time.time + 10;
        }

        GUI.enabled = true;

        if (GUILayout.Button("PARAR", GUILayout.Height(Screen.height * 0.2f)))
        {
            LocalNotification.CancelNotification(1);
            sleepUntil = 0;
        }
    }
Пример #11
0
    void OnGUI()
    {
        //Color is supported only in Android >= 5.0

        if (GUILayout.Button("5 SECONDS", GUILayout.Height(Screen.height * 0.2f)))
        {
            LocalNotification.SendNotification(1, 5, "Message from Spidy:", "I could really eat one bug or two", new Color32(0xff, 0x44, 0x44, 255));
        }

        if (GUILayout.Button("5 SECONDS BIG ICON", GUILayout.Height(Screen.height * 0.2f)))
        {
            LocalNotification.SendNotification(2, 5, "Message from Spidy:", "I could really eat one bug or two", new Color32(0xff, 0x44, 0x44, 255), true, true, true, "app_icon");
        }

        if (GUILayout.Button("EVERY 5 SECONDS", GUILayout.Height(Screen.height * 0.2f)))
        {
            LocalNotification.SendRepeatingNotification(1, 5, 5, "Message from Spidy:", "I could really eat one bug or two", new Color32(0xff, 0x44, 0x44, 255), true, false, true, "app_icon");
        }

        if (GUILayout.Button("STOP", GUILayout.Height(Screen.height * 0.2f)))
        {
            LocalNotification.CancelNotification(1);
        }
    }
 void Update()
 {
     LocalNotification.CancelNotification(3);
     coffeFull();
 }
Пример #13
0
 public void Stop()
 {
     LocalNotification.CancelNotification(1);
     print("Stop");
 }
Пример #14
0
    public void notificationSend()
    {
        string title   = this.title.text;
        string text    = this.description.text;
        string action1 = this.action1.text;
        string action2 = this.action2.text;
        long   delay   = Convert.ToInt64(this.delay.value.ToString()) * 1000;
        string type    = this.type.captionText.text;

        if (title == "")
        {
            title = "test title";
        }

        if (text == "")
        {
            text = "test text";
        }

        if (action1 == "")
        {
            action1 = "action 1";
        }

        if (action2 == "")
        {
            action2 = "action 2";
        }

        switch (type)
        {
        case "Small Icon Notification":
            status.text = "small icon notification set";
            LocalNotification.SendNotification(1, delay, title, text, new Color32(0xff, 0x44, 0x44, 255), sound.isOn, light.isOn, vibration.isOn, "app_icon", icon.captionText.text);
            break;

        case "Big Icon Notification":
            status.text = "Big icon notification set";
            LocalNotification.SendNotification(1, delay, title, text, new Color32(0xff, 0x44, 0x44, 255), sound.isOn, light.isOn, vibration.isOn, "app_icon", icon.captionText.text);
            break;

        case "Action Notification":
            status.text = "Action notification set";
            LocalNotification.Action actionBtn1 = new LocalNotification.Action("action1", action1, this);
            actionBtn1.Foreground = false;
            LocalNotification.Action actionBtn2 = new LocalNotification.Action("action2", action2, this);
            actionBtn2.Foreground = true;
            LocalNotification.SendNotification(1, delay, title, text, new Color32(0xff, 0x44, 0x44, 255), sound.isOn, light.isOn, vibration.isOn, null, icon.captionText.text, "boing", "default", actionBtn1, actionBtn2);
            break;

        case "Repeat":
            status.text = "notification repeat";
            LocalNotification.SendRepeatingNotification(1, delay, 5000, title, text, new Color32(0xff, 0x44, 0x44, 255), sound.isOn, light.isOn, vibration.isOn, null, icon.captionText.text);
            break;

        case "Stop":
            status.text = "notification stop";
            LocalNotification.CancelNotification(1);
            break;

        default:

            break;
        }
    }
Пример #15
0
    public void ChangeSettings(string setting)
    {
        switch (setting)
        {
        case "Music":

            if (musicToggle.isOn)
            {
                PlayerPrefs.SetInt("MusicOn", 1);
            }
            else
            {
                PlayerPrefs.SetInt("MusicOn", 0);
            }
            if (guiEvent != null)
            {
                guiEvent(MUSIC_EVENT);
            }
            break;

        case "Effects":
            if (effectsToggle.isOn)
            {
                PlayerPrefs.SetInt("EffectsOn", 1);
            }
            else
            {
                PlayerPrefs.SetInt("EffectsOn", 0);
            }

            if (guiEvent != null)
            {
                guiEvent(SOUND_EFFECTS_EVENT);
            }
            break;

        case "BabyMode":
            if (babymodeToggle.isOn)
            {
                PlayerPrefs.SetInt("BabyMode", 1);
                chupeta.SetActive(true);
                BABY_MODE = true;
            }
            else
            {
                PlayerPrefs.SetInt("BabyMode", 0);
                BABY_MODE = false;
                chupeta.SetActive(false);
            }

            if (guiEvent != null)
            {
                guiEvent(BABY_EVENT);
            }
            break;

        case "Notifications":
            if (notificationsToggle.isOn)
            {
                PlayerPrefs.SetInt("Notifications", 1);
                LocalNotification.SendRepeatingNotification(1, 172800, 172800, "Message from Spidy:", "I could really eat one bug or two", new Color32(0xff, 0xe1, 0x1b, 255), false, false, true, "app_icon");
            }
            else
            {
                PlayerPrefs.SetInt("Notifications", 0);
                LocalNotification.CancelNotification(1);
            }

            break;
        }
    }
 public void Stop()
 {
     LocalNotification.CancelNotification(1);
 }
    // Use this for initialization
    void Start()
    {
        if (PlayerPrefs.GetInt(StaticStrings.SoundsKey, 0) == 1)
        {
            Sounds.GetComponent <Toggle>().isOn = false;
        }

        if (PlayerPrefs.GetInt(StaticStrings.NotificationsKey, 0) == 1)
        {
            Notifications.GetComponent <Toggle>().isOn = false;
        }

        if (PlayerPrefs.GetInt(StaticStrings.VibrationsKey, 0) == 1)
        {
            Vibrations.GetComponent <Toggle>().isOn = false;
        }

        if (PlayerPrefs.GetInt(StaticStrings.FriendsRequestesKey, 0) == 1)
        {
            FriendsRequests.GetComponent <Toggle>().isOn = false;
        }

        if (PlayerPrefs.GetInt(StaticStrings.PrivateRoomKey, 0) == 1)
        {
            PrivateRoomRequests.GetComponent <Toggle>().isOn = false;
        }

        Sounds.GetComponent <Toggle>().onValueChanged.RemoveAllListeners();
        Notifications.GetComponent <Toggle>().onValueChanged.RemoveAllListeners();
        Vibrations.GetComponent <Toggle>().onValueChanged.RemoveAllListeners();
        FriendsRequests.GetComponent <Toggle>().onValueChanged.RemoveAllListeners();
        PrivateRoomRequests.GetComponent <Toggle>().onValueChanged.RemoveAllListeners();

        Sounds.GetComponent <Toggle>().onValueChanged.AddListener((value) =>
        {
            PlayerPrefs.SetInt(StaticStrings.SoundsKey, value ? 0 : 1);
            if (value)
            {
                AudioListener.volume = 1;
            }
            else
            {
                AudioListener.volume = 0;
            }
        }
                                                                  );

        Notifications.GetComponent <Toggle>().onValueChanged.AddListener((value) =>
        {
            PlayerPrefs.SetInt(StaticStrings.NotificationsKey, value ? 0 : 1);
            if (!value)
            {
                Debug.Log("Clear notifications!");
                LocalNotification.CancelNotification(1);
            }
            else
            {
                // GameObject fortune = GameObject.Find("FortuneWheelWindow");
                // if (fortune != null)
                // {
                //     fortune.GetComponent<FortuneWheelManager>().SetNextFreeTime();
                // }
            }
        }
                                                                         );

        Vibrations.GetComponent <Toggle>().onValueChanged.AddListener((value) =>
        {
            PlayerPrefs.SetInt(StaticStrings.VibrationsKey, value ? 0 : 1);
        }
                                                                      );

        FriendsRequests.GetComponent <Toggle>().onValueChanged.AddListener((value) =>
        {
            PlayerPrefs.SetInt(StaticStrings.FriendsRequestesKey, value ? 0 : 1);
        }
                                                                           );

        PrivateRoomRequests.GetComponent <Toggle>().onValueChanged.AddListener((value) =>
        {
            PlayerPrefs.SetInt(StaticStrings.PrivateRoomKey, value ? 0 : 1);
        }
                                                                               );
    }
Пример #18
0
 public void CancelNotification()
 {
     LocalNotification.CancelNotification(id);
 }