コード例 #1
0
    //new 1.5.9
    public void ScheduleSpecificLocalNotification()
    {
        Debug.Log("ScheduleLocalNotification");
        //schedule Specific notification

        //request code is the unique id of local notification
        int requestCode = REQUEST_CODE + notificationRequestCodeCollection.Count;

        int hour   = timePlugin.GetIntHour();
        int minute = timePlugin.GetIntMinute() + demoMinute1;


        int sec = timePlugin.GetIntSec();

        //1 = pm && 0 = am
        int    amOrPM = timePlugin.GetIntAmOrPm();
        string stateOfDay;

        if (amOrPM == 1)
        {
            stateOfDay = "PM";
        }
        else
        {
            stateOfDay = "AM";
        }

        if (scheduleText != null)
        {
            scheduleText.text = String.Format("H:{0} M:{1} S:{2} - {3}", hour, minute, sec, stateOfDay);
        }

        string channelID   = "MyChannelID";
        string channelName = "MyAwesomeApp";

        localNotificationPlugin.ScheduleSpecificNotification(requestCode + "ntifcation title", requestCode, hour, minute, sec, amOrPM,
                                                             "my notification message", "my notification ticker message", true, true, channelID, channelName);

        //save request code for future usage ex. canceling notification or removing it
        notificationRequestCodeCollection.Add(requestCode);

        Debug.Log("added scheduled Specific notification with requestCode " + requestCode);
    }
コード例 #2
0
    //get the time you input on text field if not available default to current time plus 5 minutes
    private void getAlarmTime()
    {
        if (hourInput != null)
        {
            if (hourInput.text.Equals("", StringComparison.Ordinal))
            {
                //default get current hour
                hour = timePlugin.GetIntHour();
                if (hour == 0)
                {
                    hour = 12;
                }
                hourInput.text = hour.ToString();
            }
            else
            {
                //hour =  int.Parse(hourInput.text);
                if (!int.TryParse(hourInput.text, out hour))
                {
                    //default get current hour
                    hour = timePlugin.GetIntHour();

                    if (hour == 0)
                    {
                        hour = 12;
                    }

                    hourInput.text = hour.ToString();
                }
                else
                {
                    if (hour >= 12)
                    {
                        hour = 12;
                    }

                    hourInput.text = hour.ToString();

                    //revert back to valid value
                    //because 0 is 12
                    if (hour >= 12)
                    {
                        hour = 0;
                    }
                }
            }
        }

        if (minuteInput != null)
        {
            if (minuteInput.text.Equals("", StringComparison.Ordinal))
            {
                minute = timePlugin.GetIntMinute() + demoMinuteAlarm;
                if (minute > 60)
                {
                    int minCorrection = (demoMinuteAlarm - (minute - 60));
                    minute = (minute - 60) + minCorrection;
                }
                minuteInput.text = minute.ToString();
            }
            else
            {
                //minute =  int.Parse(minuteInput.text);
                if (!int.TryParse(minuteInput.text, out minute))
                {
                    //default 5 minutes
                    minute = timePlugin.GetIntMinute() + demoMinuteAlarm;

                    if (minute > 60)
                    {
                        int minCorrection = (demoMinuteAlarm - (minute - 60));
                        minute = (minute - 60) + minCorrection;
                    }

                    minuteInput.text = minute.ToString();
                }
                else
                {
                    minuteInput.text = minute.ToString();
                }
            }
        }

        //sec = timePlugin.GetIntSec();
        sec = demoSecAlarm;

        //1 = pm && 0 = am
        amOrPM = timePlugin.GetIntAmOrPm();

        /*if(amOrPM == 1){
         *      stateOfDay = "PM";
         * }else{
         *      stateOfDay = "AM";
         * }*/

        //for sure
        //revert back to valid value
        //because 0 is 12
        if (hour >= 12)
        {
            hour = 0;
        }
    }