public void ScheduleLocalNotification (double addSeconds)
	{
		if (!PrefsManager.getInstance ().NotificationActive ()) {
			return;
		}

		#if UNITY_IPHONE
		LocalNotification localNotification = new LocalNotification ();
		localNotification.applicationIconBadgeNumber = 1;
		localNotification.fireDate = System.DateTime.Now.AddSeconds (addSeconds);
		localNotification.alertBody = "ジムが練習生だらけです";
		NotificationServices.CancelAllLocalNotifications ();
		NotificationServices.ScheduleLocalNotification (localNotification);
		#endif
		
		#if UNITY_ANDROID
		long secondsFromNow =  (long)addSeconds;
		string title = "ぼくたちのプロレス";
		string subTitle = "ジムが練習生だらけです";
		string tickerText = "ジムが練習生だらけです";
		string extraData = "extraData";
		EtceteraAndroid.cancelAllNotifications();
 EtceteraAndroid.scheduleNotification(secondsFromNow,title,subTitle,tickerText,extraData);
		Debug.Log("secondsFromNow = "+secondsFromNow);
		#endif
		Debug.Log("send notification");
	}
	private void ClearNotifications ()
	{
		LocalNotification localNtification = new LocalNotification ();
		localNtification.applicationIconBadgeNumber = -1;
		NotificationServices.PresentLocalNotificationNow (localNtification);
		NotificationServices.CancelAllLocalNotifications ();
		NotificationServices.ClearRemoteNotifications ();
		NotificationServices.ClearLocalNotifications ();
	}
Example #3
0
    void DidEnterRegion(object sender, CLLocationManager.DidEnterEventArgs e)
    {
        var notif = new LocalNotification();
        notif.alertBody = "Found beacon!";
        NotificationServices.PresentLocalNotificationNow(notif);

        Log("Found beacon.");
        locationManager.StartRangingBeaconsInRegion(beaconRegion);
    }
Example #4
0
    void DidExitRegion(object sender, CLLocationManager.DidExitEventArgs e)
    {
        var notif = new LocalNotification();
        notif.alertBody = "Lost beacon!";
        NotificationServices.PresentLocalNotificationNow(notif);

        Log("Left region.");
        locationManager.StopRangingBeaconsInRegion(beaconRegion);
    }
 public void OnRenderFailed()
 {
     #if UNITY_ANDROID && !UNITY_EDITOR
     using(var shimClass = new AndroidJavaClass("com.playnomics.android.unity.PlaynomicsShim"))
     {
         shimClass.CallStatic("toastMessage", new object[1] { "Render Failed" });
     }
     #elif UNITY_IPHONE  && !UNITY_EDITOR
     var notification = new LocalNotification();
     notification.alertBody = "Render Failed";
     NotificationServices.PresentLocalNotificationNow(notification);
     #endif
 }
 public void OnTouch(JsonData rawData)
 {
     //just post the message to Android Activity
     string message = string.Format("OnTouch {0}", rawData == null ? string.Empty : JsonMapper.ToJson(rawData));
     #if UNITY_ANDROID && !UNITY_EDITOR
     using(var shimClass = new AndroidJavaClass("com.playnomics.android.unity.PlaynomicsShim"))
     {
         shimClass.CallStatic("toastMessage", new object[1] { message });
     }
     #elif UNITY_IPHONE  && !UNITY_EDITOR
     var notification = new LocalNotification();
     notification.alertBody = message;
     NotificationServices.PresentLocalNotificationNow(notification);
     #endif
 }
 public void OnFetchedUserSegmentIds(List<long> userSegmentsIds)
 {
     string sval = userSegmentsIds == null ? "" : getListValue(userSegmentsIds);
     string message = string.Format("OnFetchedUserSegmentIds {0}", sval);
     //just post the message to Android Activity
     #if UNITY_ANDROID && !UNITY_EDITOR
     using(var shimClass = new AndroidJavaClass("com.playnomics.android.unity.PlaynomicsShim"))
     {
         shimClass.CallStatic("toastMessage", new object[1] { message });
     }
     #elif UNITY_IPHONE  && !UNITY_EDITOR
     var notification = new LocalNotification();
     notification.alertBody = message;
     NotificationServices.PresentLocalNotificationNow(notification);
     #endif
 }
    public void OnFetchedUserSegmentIdsError(string error, string description)
    {
        //just post the message to Android Activity
        string message = string.Format("OnFetchedUserSegmentIdsError {0}", error == null ? "" : error);

        #if UNITY_ANDROID && !UNITY_EDITOR
        using(var shimClass = new AndroidJavaClass("com.playnomics.android.unity.PlaynomicsShim"))
        {
            shimClass.CallStatic("toastMessage", new object[1] { message });
        }
        #elif UNITY_IPHONE  && !UNITY_EDITOR
        var notification = new LocalNotification();
        notification.alertBody = message;
        NotificationServices.PresentLocalNotificationNow(notification);
        #endif
    }
Example #9
0
	//通知をスケジューリングする(iOS)
	private void ScheduleLocalNotification (string message, double addSeconds) {
		LocalNotification localNotification = new LocalNotification ();
		localNotification.applicationIconBadgeNumber = 1;
		localNotification.fireDate = DateTime.Now.AddSeconds (addSeconds);
		localNotification.alertBody = message;
		NotificationServices.ScheduleLocalNotification (localNotification);
	}
Example #10
0
        public override void RepeatNotification(string message, DateTime time)
        {
            LocalNotification ntf = NewNotification(message, time, CalendarUnit.Day);

            NotificationServices.ScheduleLocalNotification(ntf);
        }
Example #11
0
 void ChangeHorse(LocalNotification e)
 {
     ChangeHorseTween();
 }
Example #12
0
 void UpdateSuccess(LocalNotification e)
 {
     AudioManager.Instance.PlayCommonAudio(GlobalData.AudioNameJoinRoomPlayer);
     ContextManager.Instance.Pop(curContext);
     ContextManager.Instance.Push(new WaitGameContext());
 }
Example #13
0
 void RefreshAllData(LocalNotification e)
 {
     InitData();
 }
Example #14
0
        private async void Save_Clicked(object sender, EventArgs e)
        {
            var courseCode       = TxtCourseCode.Text;
            var courseName       = TxtName.Text;
            var dueDate          = DtpDueDate.Date;
            var end              = DtpEnd.Date;
            var instructorEmail  = TxtInstructorEmail.Text;
            var instructorName   = TxtInstructorName.Text;
            var instructorPhone  = TxtInstructorPhone.Text;
            var name             = TxtName.Text;
            var notes            = TxtNotes.Text;
            var start            = DtpStart.Date;
            var listView         = (ObservableCollection <Assessment>)LstAssessments.ItemsSource;
            var performanceCount = 0;
            var objectiveCount   = 0;

            foreach (var item in listView)
            {
                if (item.Type == "Performance")
                {
                    performanceCount++;
                }
                if (item.Type == "Objective")
                {
                    objectiveCount++;
                }
                if (item.Name == "" || item.Name == null)
                {
                    await DisplayAlert("Warning - Invalid Data!", "Assessments must have names. Please resolve.", "Ok");

                    return;
                }
                if (item.Type == "" || item.Type == null)
                {
                    await DisplayAlert("Warning - Invalid Data!", "Assessments must have types. Please resolve.", "Ok");

                    return;
                }
                if (item.Start.Date > item.End.Date)
                {
                    await DisplayAlert("Warning - Invalid Data!", "Assessments cannot start after they end. Please resolve.", "Ok");

                    return;
                }
                if (item.End.Date < item.Start.Date)
                {
                    await DisplayAlert("Warning - Invalid Data!", "Assessments cannot end before they end. Please resolve.", "Ok");

                    return;
                }

                if (item.Start.Date > dueDate.Date)
                {
                    await DisplayAlert("Warning - Invalid Data!", "Assessments cannot start after the term/course due date. Please resolve.", "Ok");

                    return;
                }
                if (item.End.Date > dueDate.Date)
                {
                    await DisplayAlert("Warning - Invalid Data!", "Assessments cannot end after the term/course due date. Please resolve.", "Ok");

                    return;
                }
                if (item.Start.Date < start.Date)
                {
                    await DisplayAlert("Warning - Invalid Data!", "Assessments cannot start before the course start date.", "Ok");

                    return;
                }
                if (item.Start.Date > end.Date)
                {
                    await DisplayAlert("Warning - Invalid Data!", "Assessments cannot start after the course end date.", "Ok");

                    return;
                }
                if (item.End.Date < start.Date)
                {
                    await DisplayAlert("Warning - Invalid Data!", "Assessments cannot end before the course start date.", "Ok");

                    return;
                }
                if (item.End.Date > end.Date)
                {
                    await DisplayAlert("Warning - Invalid Data!", "Assessments cannot end after the course end date.", "Ok");

                    return;
                }
                if (objectiveCount > 1 || performanceCount > 1)
                {
                    await DisplayAlert("Warning - Invalid Data!", "There may only be on performance and one objective assessment selected.", "Ok");

                    return;
                }
            }

            var course  = _course[0];
            int cu      = 0;
            var validCu = (int.TryParse(TxtCu.Text, out int n));

            if (validCu)
            {
                cu = Convert.ToInt32(TxtCu.Text);
            }

            var status     = "";
            var statusNull = (PkrStatus.SelectedItem == null);

            if (!statusNull)
            {
                status = PkrStatus.SelectedItem.ToString();
            }

            //cu = 3;
            //courseCode = "C001";
            //dueDate = DateTime.Now;
            //end = DateTime.Now;
            //instructorEmail = "*****@*****.**";
            //instructorName = "instructor";
            //instructorPhone = "1111111111";
            //name = "Intro to whatever";
            //notes = "Notes";
            //start = DateTime.Now;
            //status = "In Progress";

            //// Setup regex for phone and postal code validations
            var phoneRegex         = new Regex(@"^(\+\d{1,2}\s)?\(?\d{3}\)?[\s.-]?\d{3}[\s.-]?\d{4}$");
            var emailRegex         = new Regex(@"^([\w\.\-]+)@([\w\-]+)((\.(\w){2,3})+)$");
            var noCode             = (courseCode == "" || courseCode == null);
            var noName             = (name == "" || name == null);
            var invalidPhoneNumber = false;

            if (instructorPhone != null && !phoneRegex.IsMatch(instructorPhone))
            {
                invalidPhoneNumber = true;
            }
            var invalidEmail = false;

            if (instructorEmail != null && !emailRegex.IsMatch(instructorEmail))
            {
                invalidEmail = true;
            }

            if (instructorName == "" || instructorName == null)
            {
                await DisplayAlert("Warning - Invalid Data!", "Please enter an instructor name.", "Ok");

                return;
            }
            else if (instructorPhone == "" || instructorPhone == null)
            {
                await DisplayAlert("Warning - Invalid Data!", "Please enter an instructor phone number.", "Ok");

                return;
            }
            else if (instructorEmail == "" || instructorEmail == null)
            {
                await DisplayAlert("Warning - Invalid Data!", "Please enter an instructor email address.", "Ok");

                return;
            }
            else if (!validCu)
            {
                await DisplayAlert("Warning - Invalid Data!", "Course CUs must be a numeric value.", "Ok");

                return;
            }
            else if (statusNull)
            {
                await DisplayAlert("Warning - Missing Data!", "Courses must have a status.", "Ok");

                return;
            }
            else if (noName)
            {
                await DisplayAlert("Warning - Missing Data!", "Courses must have a course name.", "Ok");

                return;
            }
            else if (noCode)
            {
                await DisplayAlert("Warning - Missing Data!", "Courses must have a course code.", "Ok");

                return;
            }
            else if (invalidPhoneNumber)
            {
                await DisplayAlert("Warning - Invalid Data!", "The phone number you have entered is not a proper phone number format.\n\nAppropriate style examples would be:\n\n123-456-7890\n(123)456-7890\n123 456 7890\n123.456.7890\n+ 91(123) 456-7890\n1234567890", "Ok");

                return;
            }
            else if (invalidEmail)
            {
                await DisplayAlert("Warning - Missing Data!", "The email adddress you have entered is not a proper email address format.", "Ok");

                return;
            }
            //else if (start < DateTime.Now.Date && _addFlag)
            //{
            //    await DisplayAlert("Warning - Data Problem!", "Start dates must not be in the past.", "Ok");
            //    return;
            //}
            //else if (end < DateTime.Now.Date && _addFlag)
            //{
            //    await DisplayAlert("Warning - Data Problem!", "End dates must not be in the past.", "Ok");
            //    return;
            //}
            else if (start.Date > end.Date)
            {
                await DisplayAlert("Warning - Data Problem!", "Start date cannot be after end date.", "Ok");

                return;
            }
            else if (end.Date > dueDate.Date)
            {
                await DisplayAlert("Warning - Data Problem!", "End date cannot be after due date.", "Ok");

                return;
            }
            else if (start.Date > dueDate.Date)
            {
                await DisplayAlert("Warning - Data Problem!", "Start date cannot be after due date.", "Ok");

                return;
            }
            else
            {
                var notifications = await App.Database.GetNotificationsAsync();

                var filteredNotes = notifications.Where(r => r.CourseId == course.Id).ToList();

                if (filteredNotes.Count > 0)
                {
                    foreach (var note in filteredNotes)
                    {
                        await App.Database.DeleteNotificationAsync(note);

                        CrossLocalNotifications.Current.Cancel(note.Id);
                    }
                }

                var courseId = course.Id;

                var title   = "Course updated.";
                var message = "Your course has been updated.";
                if (_addFlag)
                {
                    title   = "Course added.";
                    message = "Your course has been added.";
                }

                //temp

                course.Cu              = cu;
                course.TermId          = _term[0].Id;
                course.CourseCode      = courseCode;
                course.DueDate         = dueDate;
                course.End             = end;
                course.InstructorEmail = instructorEmail;
                course.InstructorName  = instructorName;
                course.InstructorPhone = instructorPhone;
                course.Name            = name;
                course.Notes           = notes;
                course.Start           = start;
                course.Status          = status;

                await App.Database.SaveCourseAsync(_course[0]);

                // Delete all assessments and notifications for course
                var assessments = await App.Database.GetAssessmentsAsync();

                var filteredAssessments = assessments.Where(r => r.CourseId == course.Id).ToList();
                if (filteredAssessments.Count > 0)
                {
                    foreach (var record in filteredAssessments)
                    {
                        var notez = await App.Database.GetNotificationsAsync();

                        var filteredNotez = notez.Where(r => r.AssessmentId == record.Id).ToList();

                        await App.Database.DeleteAssessmentAsync(record);

                        _assessments.Remove(record);

                        foreach (var note in filteredNotez)
                        {
                            await App.Database.DeleteNotificationAsync(note);
                        }
                    }
                }

                // WARNING FOR WHEN I TRY TO MAKE THIS BETTER:
                // CROSSLOCALNOTIFICATIONS IS DIFFICULT TO WORK WITH.... I had to break this out into repeated non-dynamic code because shared code cause days of problems
                // Also really hates working with objects that come from collections.... the objects cant be form a collection, new objects need to be created for each
                // collection item.
                // Tread cautiously...

                var noteMessage = "";
                var noteTitle   = "";

                if (course.Start.Date == DateTime.Now.Date)
                {
                    var action = "Starting";
                    var date   = course.Start;

                    noteMessage = $"{action} today:\n\n{course.CourseCode} - {course.Name}";
                    noteTitle   = $"{course.CourseCode} - {action} today";
                    var newNote = new LocalNotification(0, noteTitle, noteMessage, date, course.Id, -1);

                    await App.Database.SaveNotificationAsync(newNote);

                    CrossLocalNotifications.Current.Show(noteTitle, noteMessage, newNote.Id, date);
                }
                if (course.End.Date == DateTime.Now.Date)
                {
                    var action = "Ending";
                    var date   = course.End;

                    noteMessage = $"{action} today:\n\n{course.CourseCode} - {course.Name}";
                    noteTitle   = $"{course.CourseCode} - {action} today";
                    var newNote = new LocalNotification(0, noteTitle, noteMessage, date, course.Id, -1);

                    await App.Database.SaveNotificationAsync(newNote);

                    CrossLocalNotifications.Current.Show(noteTitle, noteMessage, newNote.Id, date);
                }

                // Add assessments from listitems to the database and create notifications
                var assessmentsSource = (ObservableCollection <Assessment>)LstAssessments.ItemsSource;

                if (assessmentsSource.Count > 1)
                {
                    var newAssessment = new Assessment(0, assessmentsSource[1].Name, assessmentsSource[1].Start, assessmentsSource[1].End, assessmentsSource[1].Type, course.Id);
                    await App.Database.SaveAssessmentAsync(newAssessment);

                    if (_assessments != null)
                    {
                        _assessments.Add(newAssessment);
                    }
                    else
                    {
                        _assessments = new ObservableCollection <Assessment>
                        {
                            newAssessment
                        };
                    }

                    if (newAssessment.Start.Date == DateTime.Now.Date)
                    {
                        var action = "Starting";
                        var date   = newAssessment.Start;

                        // Add new notification
                        noteMessage = $"{action} today:\n\n{course.CourseCode} - {course.Name}";
                        noteTitle   = $"{course.CourseCode} - {newAssessment.Name} - {action} today";
                        var newNote = new LocalNotification(0, noteTitle, noteMessage, date, course.Id, newAssessment.Id);

                        await App.Database.SaveNotificationAsync(newNote);

                        CrossLocalNotifications.Current.Show(noteTitle, noteMessage, newNote.Id, date);
                    }

                    if (newAssessment.End.Date == DateTime.Now.Date)
                    {
                        var action = "Ending";
                        var date   = newAssessment.End;

                        // Add new notification
                        noteMessage = $"{action} today:\n\n{course.CourseCode} - {course.Name}";
                        noteTitle   = $"{course.CourseCode} - {newAssessment.Name} - {action} today";
                        var newNote = new LocalNotification(0, noteTitle, noteMessage, date, course.Id, newAssessment.Id);

                        await App.Database.SaveNotificationAsync(newNote);

                        CrossLocalNotifications.Current.Show(noteTitle, noteMessage, newNote.Id, date);
                    }
                }

                if (assessmentsSource.Count > 0)
                {
                    var anotherAssessment = new Assessment(0, assessmentsSource[0].Name, assessmentsSource[0].Start, assessmentsSource[0].End, assessmentsSource[0].Type, course.Id);
                    await App.Database.SaveAssessmentAsync(anotherAssessment);

                    if (_assessments != null)
                    {
                        _assessments.Add(anotherAssessment);
                    }
                    else
                    {
                        _assessments = new ObservableCollection <Assessment>
                        {
                            anotherAssessment
                        };
                    }

                    if (anotherAssessment.Start.Date == DateTime.Now.Date)
                    {
                        var action = "Starting";
                        var date   = anotherAssessment.Start;

                        // Add new notification
                        noteMessage = $"{action} today:\n\n{course.CourseCode} - {course.Name}";
                        noteTitle   = $"{course.CourseCode} - {anotherAssessment.Name} - {action} today";
                        var newNote = new LocalNotification(0, noteTitle, noteMessage, date, course.Id, anotherAssessment.Id);

                        await App.Database.SaveNotificationAsync(newNote);

                        CrossLocalNotifications.Current.Show(noteTitle, noteMessage, newNote.Id, date);
                    }

                    if (anotherAssessment.End.Date == DateTime.Now.Date)
                    {
                        var action = "Ending";
                        var date   = anotherAssessment.End;

                        // Add new notification
                        noteMessage = $"{action} today:\n\n{course.CourseCode} - {course.Name}";
                        noteTitle   = $"{course.CourseCode} - {anotherAssessment.Name} - {action} today";
                        var newNote = new LocalNotification(0, noteTitle, noteMessage, date, course.Id, anotherAssessment.Id);

                        await App.Database.SaveNotificationAsync(newNote);

                        CrossLocalNotifications.Current.Show(noteTitle, noteMessage, newNote.Id, date);
                    }
                }

                await DisplayAlert(title, message, "Ok");

                Return();
            }
        }
Example #15
0
 void Awake()
 {
     LocalNotification.ClearNotifications();
 }
Example #16
0
 void UpdateOtherJoin(LocalNotification e)
 {
     AudioManager.Instance.PlayCommonAudio(GlobalData.AudioNameJoinRoomPlayer);
     RefreshRoomPlayer(); //刷新显示
 }
Example #17
0
 void UpdateOtherLeaveJoin(LocalNotification e)
 {
     AudioManager.Instance.PlayCommonAudio(GlobalData.AudioNameOtherLeaveRoom);
     ResetStopGameTime();
     RefreshRoomPlayer(); //刷新显示
 }
Example #18
0
 void ReconnectToPlaying(LocalNotification e)
 {
     PlayingGameInfo.Instance.mReconnectId = 2; //断线重连
     GameManager.Instance.SwitchGameStatus(EGameStatus.EPlaying);
 }
Example #19
0
 public void Repeating()
 {
     LocalNotification.SendRepeatingNotification(1, 5000, 60000, "Title", "Long message text", new Color32(0xff, 0x44, 0x44, 255));
 }
Example #20
0
 public void OneTimeBigIcon()
 {
     NotificationManager.SendWithAppIcon(TimeSpan.FromSeconds(5), "Notification", "Notification with app icon", new Color(0, 0.6f, 1), NotificationIcon.Message);
     LocalNotification.SendNotification(1, 5000, "Title", "Long message text with big icon", new Color32(0xff, 0x44, 0x44, 255), true, true, true, "app_icon");
 }
Example #21
0
    // Update is called once per frame
    void Update()
    {
        if (PlayerPrefs.GetInt("CoinGold") > 50)
        {
            Social.ReportProgress(AchievementsJS.achievement_gold_collector, 100.0f, (bool success) => {
                // handle success or failure
            });
        }
        if (PlayerPrefs.GetInt("CoinBronze") > 50)
        {
            Social.ReportProgress(AchievementsJS.achievement_bronze_collector, 100.0f, (bool success) => {
                // handle success or failure
            });
        }
        if (PlayerPrefs.GetInt("CoinBronze") > 100 && PlayerPrefs.GetInt("CoinGold") > 100)
        {
            Social.ReportProgress(AchievementsJS.achievement_real_collector, 100.0f, (bool success) => {
                // handle success or failure
            });
        }
        if (PlayerPrefs.GetInt("languageSelection") == 0)
        {
            DeathTryText.fontSize = 250;
            DeathScoreText.GetComponent <Text> ().alignment = TextAnchor.UpperCenter;
            LanguageManager.Instance.ChangeLanguage("en");
        }
        else if (PlayerPrefs.GetInt("languageSelection") == 1)
        {
            DeathTryText.fontSize = 250;
            DeathScoreText.GetComponent <Text> ().alignment = TextAnchor.UpperCenter;
            LanguageManager.Instance.ChangeLanguage("tr");
        }
        else if (PlayerPrefs.GetInt("languageSelection") == 2)
        {
            LanguageManager.Instance.ChangeLanguage("de");
            DeathTryText.fontSize = 220;
            DeathScoreText.GetComponent <Text> ().alignment = TextAnchor.UpperLeft;
        }
        else
        {
            LanguageManager.Instance.ChangeLanguage("en");
            DeathScoreText.GetComponent <Text> ().alignment = TextAnchor.UpperCenter;
            DeathTryText.fontSize = 250;
        }

        bgg = PlayerPrefs.GetInt("selectedBG");
        if (ColliderLight.position.y + 1f < transform.position.y)
        {
            if (bgg == 1)
            {
                texts [0].color  = new Color32(0, 0, 0, 50);
                texts [1].color  = new Color32(0, 0, 0, 50);
                texts [2].color  = new Color32(0, 0, 0, 50);
                texts [3].color  = new Color32(0, 0, 0, 50);
                coinGold.color   = new Color32(255, 255, 255, 50);
                coinBronze.color = new Color32(255, 255, 255, 50);
                texts [4].color  = new Color32(0, 0, 0, 50);
            }
            else
            {
                texts [0].color  = new Color32(255, 255, 255, 50);
                texts [1].color  = new Color32(255, 255, 255, 50);
                texts [2].color  = new Color32(255, 255, 255, 50);
                texts [3].color  = new Color32(255, 255, 255, 50);
                coinGold.color   = new Color32(255, 255, 255, 50);
                coinBronze.color = new Color32(255, 255, 255, 50);
                texts [4].color  = new Color32(255, 255, 255, 50);
            }
        }
        else
        {
            if (bgg == 1)
            {
                for (int i = 0; i < texts.Length; i++)
                {
                    texts [i].color  = new Color32(0, 0, 0, 255);
                    coinGold.color   = new Color32(255, 255, 255, 255);
                    coinBronze.color = new Color32(255, 255, 255, 255);
                }
            }
            else
            {
                for (int i = 0; i < texts.Length; i++)
                {
                    texts [i].color  = new Color32(255, 255, 255, 255);
                    coinGold.color   = new Color32(255, 255, 255, 255);
                    coinBronze.color = new Color32(255, 255, 255, 255);
                }
            }
        }
        PlayerPrefs.SetInt("ESC", 1);
        //grounded = Physics2D.IsTouchingLayers (MCollider, GroundOrAir);

        grounded = Physics2D.OverlapCircle(groundCheck.position, groundCheckRadius, GroundOrAir);

        if (transform.position.x > speedCount && speedUp)
        {
            if (PlayerPrefs.GetInt("SpeedUPP") == 1)
            {
                speedCount   += speedIncrease;
                speedIncrease = speedIncrease + (speedAdder * 10);
                //moveSpeedL = moveSpeed;
                moveSpeed  = moveSpeed + speedAdder;
                speedAdder = 0f;
                if (moveSpeed != 0f)
                {
                    thePauseMenu.SetActive(false);
                    PlayerPrefs.SetInt("NOStuck", 1);

                    PlayerPrefs.SetFloat("moveSpeed", moveSpeed);
                }
            }
        }

        MRigidbody.velocity = new Vector2(moveSpeed, MRigidbody.velocity.y);
        if ((Input.GetKeyDown(KeyCode.Space)) || (Input.GetMouseButtonDown(0)) && !jumpOff)
        {
            //LocalNotification.SendRepeatingNotification(1, 21600, 86400, LanguageManager.Instance.GetTextValue("notif00"), LanguageManager.Instance.GetTextValue("notif01"), new Color32(0xff, 0x44, 0x44, 255),true,false,true);
            if (PlayerPrefs.GetInt("languageSelection") == 0)
            {
                LocalNotification.SendRepeatingNotification(1, 21600, 86400, "Can you solve?", "Try and see :)", new Color32(0xff, 0x44, 0x44, 255), true, false, true);
                sleepUntil = Time.time + 99999;
            }
            if (PlayerPrefs.GetInt("languageSelection") == 0)
            {
                LocalNotification.SendRepeatingNotification(1, 21600, 86400, "Çözebilir misin?", "Dene ve gör :)", new Color32(0xff, 0x44, 0x44, 255), true, false, true);
                sleepUntil = Time.time + 99999;
            }
            Debug.Log("Notification Active");
            if (grounded)
            {
                if (PlayerPrefs.GetString("StopMusic") != "stop")
                {
                    MundoSound.Play(jumpEffect, soundEffect, false);
                }
                MRigidbody.velocity = new Vector2(MRigidbody.velocity.x, jumpForce);
                stoppedJumping      = false;
            }
            if (!grounded && canDoublejump)
            {
                MundoSound.Play(jumpEffect, soundEffect, false);
                canDoublejump       = false;
                stoppedJumping      = false;
                jumpTimeCounter     = jumpTime;
                MRigidbody.velocity = new Vector2(MRigidbody.velocity.x, jumpForce);
            }
        }
        if ((Input.GetKey(KeyCode.Space) || (Input.GetMouseButton(0)) && !stoppedJumping && !jumpOff))
        {
            if (jumpTimeCounter > 0)
            {
                MRigidbody.velocity = new Vector2(MRigidbody.velocity.x, jumpForce);
                jumpTimeCounter    -= Time.deltaTime;
            }
        }
        if (Input.GetKeyUp(KeyCode.Space) || (Input.GetMouseButtonUp(0)))
        {
            jumpTimeCounter = 0;
            stoppedJumping  = true;
        }

        if (grounded)
        {
            speedAdder      = 0.75f;
            canDoublejump   = true;
            jumpTimeCounter = jumpTime;
            switch (selectCharacter)
            {
            case 0:
                lastGroundedPos = thePlayerBlue.transform.position;
                break;

            case 1:
                lastGroundedPos = thePlayerRed.transform.position;
                break;

            case 2:
                lastGroundedPos = thePlayerGreen.transform.position;
                break;

            case 3:
                lastGroundedPos = thePlayerGrey.transform.position;
                break;

            case 4:
                lastGroundedPos = thePlayerAlienBlue.transform.position;
                break;

            case 5:
                lastGroundedPos = thePlayerTruckRed.transform.position;
                break;

            case 6:
                lastGroundedPos = thePlayerTruckYellow.transform.position;
                break;

            case 7:
                lastGroundedPos = thePlayerTruckBlue.transform.position;
                break;

            case 8:
                lastGroundedPos = thePlayerTruckGreen.transform.position;
                break;

            case 9:
                lastGroundedPos = thePlayerRedDisk.transform.position;
                break;

            case 10:
                lastGroundedPos = thePlayerBlueReverse.transform.position;
                break;

            case 11:
                lastGroundedPos = thePlayerRedReverse.transform.position;
                break;

            case 12:
                lastGroundedPos = thePlayerGreenReverse.transform.position;
                break;

            case 13:
                lastGroundedPos = thePlayerGreyReverse.transform.position;
                break;

            case 14:
                lastGroundedPos = thePlayerDevil.transform.position;
                break;

            case 15:
                lastGroundedPos = thePlayerAlienBiege.transform.position;
                break;

            case 16:
                lastGroundedPos = thePlayerAlienYellow.transform.position;
                break;

            case 17:
                lastGroundedPos = thePlayerAlienDarkBlue.transform.position;
                break;

            case 18:
                lastGroundedPos = thePlayerAlienPink.transform.position;
                break;
            }
        }

        if (Input.GetKeyUp(KeyCode.Escape))
        {
            //theManager.escape = true;
            if (PlayerPrefs.GetString("NOTPAUSE") == "pause")
            {
                PlayerPrefs.SetInt("ScrollBGStop", 0);
                PPause();
            }
            else if (PlayerPrefs.GetString("NOTPAUSE") == "not")
            {
                Debug.Log("NOT PAUSEE :)");
            }
        }

        switch (selectCharacter)
        {
        case 0:
            MAnimatorBlue.SetBool("Grounded", grounded);
            MAnimatorBlue.SetFloat("Speed", MRigidbody.velocity.x);
            break;

        case 1:
            MAnimatorRed.SetBool("GroundRed", grounded);
            MAnimatorRed.SetFloat("SpeedRed", MRigidbody.velocity.x);
            break;

        case 2:
            MAnimatorGreen.SetBool("GroundGreen", grounded);
            MAnimatorGreen.SetFloat("SpeedGreen", MRigidbody.velocity.x);
            break;

        case 3:
            MAnimatorGrey.SetBool("GroudGrey", grounded);
            MAnimatorGrey.SetFloat("SpeedGrey", MRigidbody.velocity.x);
            break;

        case 4:
            MAnimatorAlienBlue.SetBool("GroundAlienBlue", grounded);
            MAnimatorAlienBlue.SetFloat("SpeedAlienBlue", MRigidbody.velocity.x);
            break;

        case 5:
            MAnimatorTruckRed.SetBool("GroundTruckRed", grounded);
            MAnimatorTruckRed.SetFloat("SpeedTruckRed", MRigidbody.velocity.x);
            break;

        case 6:
            MAnimatorTruckYellow.SetBool("GroundTruckYellow", grounded);
            MAnimatorTruckYellow.SetFloat("SpeedTruckYellow", MRigidbody.velocity.x);
            break;

        case 7:
            MAnimatorTruckBlue.SetBool("GroundTruckBlue", grounded);
            MAnimatorTruckBlue.SetFloat("SpeedTruckBlue", MRigidbody.velocity.x);
            break;

        case 8:
            MAnimatorTruckGreen.SetBool("GroundTruckGreen", grounded);
            MAnimatorTruckGreen.SetFloat("SpeedTruckGreen", MRigidbody.velocity.x);
            break;

        case 9:
            MAnimatorDiskRed.SetBool("GroundDiskRed", grounded);
            MAnimatorDiskRed.SetFloat("SpeedDiskRed", MRigidbody.velocity.x);
            break;

        case 10:
            MAnimatorBlueReverse.SetBool("GroundBlueReverse", grounded);
            MAnimatorBlueReverse.SetFloat("SpeedBlueReverse", MRigidbody.velocity.x);
            break;

        case 11:
            MAnimatorRedReverse.SetBool("GroundRedReverse", grounded);
            MAnimatorRedReverse.SetFloat("SpeedRedReverse", MRigidbody.velocity.x);
            break;

        case 12:
            MAnimatorGreenReverse.SetBool("GroundGreenReverse", grounded);
            MAnimatorGreenReverse.SetFloat("SpeedGreenReverse", MRigidbody.velocity.x);
            break;

        case 13:
            MAnimatorGreyReverse.SetBool("GroundGreyReverse", grounded);
            MAnimatorGreyReverse.SetFloat("SpeedGreyReverse", MRigidbody.velocity.x);
            break;

        case 14:
            MAnimatorDevil.SetBool("GroundDevil", grounded);
            MAnimatorDevil.SetFloat("SpeedDevil", MRigidbody.velocity.x);
            break;

        case 15:
            MAnimatorAlienBiege.SetBool("GroundAlienBiege", grounded);
            MAnimatorAlienBiege.SetFloat("SpeedAlienBiege", MRigidbody.velocity.x);
            break;

        case 16:
            MAnimatorAlienYellow.SetBool("GroundAlienYellow", grounded);
            MAnimatorAlienYellow.SetFloat("SpeedAlienYellow", MRigidbody.velocity.x);
            break;

        case 17:
            MAnimatorAlienDarkBlue.SetBool("GroundAlienDarkBlue", grounded);
            MAnimatorAlienDarkBlue.SetFloat("SpeedAlienDarkBlue", MRigidbody.velocity.x);
            break;

        case 18:
            MAnimatorAlienPink.SetBool("GroundAlienPink", grounded);
            MAnimatorAlienPink.SetFloat("SpeedAlienPink", MRigidbody.velocity.x);
            break;
        }

        timeF = 1 * Time.fixedTime;
        timeI = (int)Mathf.Round(timeF);

        switch (selectCharacter)
        {
        case 0:
            lastGrounded2 = thePlayerBlue.transform.position;
            break;

        case 1:
            lastGrounded2 = thePlayerRed.transform.position;
            break;

        case 2:
            lastGrounded2 = thePlayerGreen.transform.position;
            break;

        case 3:
            lastGrounded2 = thePlayerGrey.transform.position;
            break;

        case 4:
            lastGrounded2 = thePlayerAlienBlue.transform.position;
            break;

        case 5:
            lastGrounded2 = thePlayerTruckRed.transform.position;
            break;

        case 6:
            lastGrounded2 = thePlayerTruckYellow.transform.position;
            break;

        case 7:
            lastGrounded2 = thePlayerTruckBlue.transform.position;
            break;

        case 8:
            lastGrounded2 = thePlayerTruckGreen.transform.position;
            break;

        case 9:
            lastGrounded2 = thePlayerRedDisk.transform.position;
            break;

        case 10:
            lastGrounded2 = thePlayerBlueReverse.transform.position;
            break;

        case 11:
            lastGrounded2 = thePlayerRedReverse.transform.position;
            break;

        case 12:
            lastGrounded2 = thePlayerGreenReverse.transform.position;
            break;

        case 13:
            lastGrounded2 = thePlayerGreyReverse.transform.position;
            break;

        case 14:
            lastGrounded2 = thePlayerDevil.transform.position;
            break;

        case 15:
            lastGrounded2 = thePlayerAlienBiege.transform.position;
            break;

        case 16:
            lastGrounded2 = thePlayerAlienYellow.transform.position;
            break;

        case 17:
            lastGrounded2 = thePlayerAlienDarkBlue.transform.position;
            break;

        case 18:
            lastGrounded2 = thePlayerAlienPink.transform.position;
            break;
        }
        //timeF = Time.deltaTime;

        for (timeI = (int)Mathf.Round(timeF); timeF == t; t++)
        {
            /*if (minus != 0) {
             *
             *
             *      if (minus == minusB) {
             *              timeAdd -= 0.75f * minusB / 3;
             *              minusB += 3;
             *              PlayerPrefs.SetFloat ("TimeAdded", timeAdd);
             *
             *      }*/


            //}

            timeAdd += 0.75f;
            PlayerPrefs.SetFloat("TimeAdded", timeAdd);

            t = t + 3;
        }
        timeAdded = PlayerPrefs.GetFloat("TimeAdded");
    }
        // 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);
            }
                                                                                   );
        }
Example #23
0
 public void Stop()
 {
     LocalNotification.CancelNotification(1);
 }
Example #24
0
 void UpdateReadyGame(LocalNotification e)
 {
     //倒计时开始,倒计时结束后向服务器发送开始游戏请求.
     isStartTime = true;
 }
Example #25
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;
        }
    }
Example #26
0
 void UpdateLevelRoom(LocalNotification e)
 {
     ContextManager.Instance.Pop(this.curContext);
 }
Example #27
0
 private void RefreshData(LocalNotification info)
 {
     InitData();
 }
Example #28
0
 void UpdateSameIpPlayer(LocalNotification args)
 {
     Debug.Log("SameIpView");
     StartCoroutine(LoadSameIpView(args));
 }
Example #29
0
 void UpdateFKBZ(LocalNotification e)
 {
     UIManagers.Instance.EnqueueTip("房卡不足");
 }
Example #30
0
 void UpdateGoldNotEnough(LocalNotification e)
 {
     ContextManager.Instance.Push(new ShopContext());
 }
Example #31
0
 void UpdateJoinRoomSuc(LocalNotification e)
 {
     ContextManager.Instance.Pop(curContext);
 }
        public void LocalNotification(string title, string body, int id, DateTime notifyTime, string frecuencia, string tiempo)
        {
            CreateNotificationChannel();
            //long repeateDay = 1000 * 60 * 60 * 24;
            long repeateForMinute = 60000;               // In milliseconds
            long repiteDiario     = 1000 * 60 * 60 * 24; //Cada dia
            long repite12Horas    = 1000 * 60 * 60 * 12; //cada 12 horas
            long tiempoRepeticion = 0;


            if (System.String.Equals(tiempo, "HORAS"))
            {
                if (System.String.Equals(frecuencia, "24"))
                {
                    tiempoRepeticion = repiteDiario;
                    //tiempoRepeticion = repeateForMinute * 2;
                }
                if (System.String.Equals(frecuencia, "12"))
                {
                    tiempoRepeticion = repite12Horas;
                    //tiempoRepeticion = repeateForMinute;
                }
            }
            if (System.String.Equals(tiempo, "DIAS"))
            {
                //tiempoRepeticion = repeateForMinute * 2;
                tiempoRepeticion = repiteDiario * Long.ParseLong(frecuencia);
            }



            long totalMilliSeconds = (long)(notifyTime.ToUniversalTime() - _jan1st1970).TotalMilliseconds;

            if (totalMilliSeconds < JavaSystem.CurrentTimeMillis())
            {
                //totalMilliSeconds = totalMilliSeconds + repeateForMinute;
                totalMilliSeconds = totalMilliSeconds + tiempoRepeticion;
            }

            var intent            = CreateIntent(id);
            var localNotification = new LocalNotification();

            localNotification.Title      = title;
            localNotification.Body       = body;
            localNotification.Id         = id;
            localNotification.NotifyTime = notifyTime;

            if (_notificationIconId != 0)
            {
                localNotification.IconId = _notificationIconId;
            }
            else
            {
                localNotification.IconId = Resource.Drawable.xamagonBlue;
            }

            var serializedNotification = SerializeNotification(localNotification);

            intent.PutExtra(ScheduledAlarmHandler.LocalNotificationKey, serializedNotification);

            Random generator = new Random();

            _randomNumber = generator.Next(100000, 999999).ToString("D6");

            var pendingIntent = PendingIntent.GetBroadcast(Application.Context, Convert.ToInt32(_randomNumber), intent, PendingIntentFlags.Immutable);
            var alarmManager  = GetAlarmManager();

            // alarmManager.SetRepeating(AlarmType.RtcWakeup, totalMilliSeconds, repeateForMinute, pendingIntent); //cada 1 minutoo
            alarmManager.SetRepeating(AlarmType.RtcWakeup, totalMilliSeconds, tiempoRepeticion, pendingIntent); //cada 12 minutos
        }
		public static void PresentLocalNotificationNow(LocalNotification notification){}
Example #34
0
        public override void ScheduleNotification(string message, DateTime time)
        {
            LocalNotification ntf = NewNotification(message, time);

            NotificationServices.ScheduleLocalNotification(ntf);
        }
Example #35
0
        //Please note that the actual interval may be different.
        //On iOS there are only fixed options like every minute, every day, every week and so on. So the provided <c>intervalSeconds</c> value will be approximated by one of the available options.
        public override void ScheduleNotificationRepeating(int firstTriggerInSeconds, int intervalSeconds, string title, string text, int id, IDictionary <string, string> userData, string notificationProfile, int badgeNumber, ICollection <Button> buttons)
        {
            if (!CheckInitialized())
            {
                return;
            }

            LocalNotification notification = CreateLocalNotification(title, text, id, userData, notificationProfile, badgeNumber);

            notification.fireDate = System.DateTime.Now.AddSeconds(firstTriggerInSeconds);
            if (intervalSeconds < 3)
            {
                //Approximate it to every second if the desired intervalSeconds is less then 3 seconds
                notification.repeatInterval = CalendarUnit.Second;
            }
            else if (intervalSeconds < 3 * 60)
            {
                //Approximate it to every minute if the desired intervalSeconds is less then 3 minutes
                notification.repeatInterval = CalendarUnit.Minute;
            }
            else if (intervalSeconds < 3 * 60 * 60)
            {
                //Approximate it to every hour if the desired intervalSeconds is less then 3 hours
                notification.repeatInterval = CalendarUnit.Hour;
            }
            else if (intervalSeconds < 3 * 24 * 60 * 60)
            {
                //Approximate it to every day if the desired intervalSeconds is less then 3 days
                notification.repeatInterval = CalendarUnit.Day;
            }
            else if (intervalSeconds < 3 * 7 * 24 * 60 * 60)
            {
                //Approximate it to every week if the desired intervalSeconds is less then 3 weeks
                notification.repeatInterval = CalendarUnit.Week;
            }
            else if (intervalSeconds < 2 * 31 * 24 * 60 * 60)
            {
                //Approximate it to every month if the desired intervalSeconds is less then 2 months
                notification.repeatInterval = CalendarUnit.Month;
            }
            else if (intervalSeconds < 183 * 24 * 60 * 60)
            {
                //Approximate it to every quarter if the desired intervalSeconds is less then half a year
                notification.repeatInterval = CalendarUnit.Quarter;
            }
            else if (intervalSeconds < 3 * 365 * 24 * 60 * 60)
            {
                //Approximate it to every year if the desired intervalSeconds is less then 3 years
                notification.repeatInterval = CalendarUnit.Year;
            }
            else
            {
                UnityEngine.Debug.LogWarning("Suspicious intervalSeconds value provided: " + intervalSeconds);
                notification.repeatInterval = CalendarUnit.Era;
            }

            if (m_enabled)
            {
                NotificationServices.ScheduleLocalNotification(notification);
            }
            else
            {
                if (m_scheduledNotificationsWhenDisabled == null)
                {
                    m_scheduledNotificationsWhenDisabled = new List <ScheduledNotification>();
                }
                m_scheduledNotificationsWhenDisabled.Add(ToScheduledNotification(notification, DateTime.Now));
                SaveScheduledNotificationsWhenDisabled();
            }
        }
Example #36
0
    void TestReceveMsg(LocalNotification e)
    {
        ArgsMsgTest args = e.param as ArgsMsgTest;

        HangleLog("=======================================" + args.testStr, "DDDDDDDDDDD", LogType.Log);
    }
		public static void ScheduleLocalNotification(LocalNotification notification){}
Example #38
0
 public void OneTime()
 {
     LocalNotification.SendNotification(1, 5000, "Title", "Long message text", new Color32(0xff, 0x44, 0x44, 255));
 }
		public static void CancelLocalNotification(LocalNotification notification){}
Example #40
0
 public void Repeating()
 {
     LocalNotification.SendRepeatingNotification(1, 1, 60, "Три карты", "НИЧООООООООООООООСИ", new Color32(0xff, 0x44, 0x44, 255));
 }
Example #41
0
 public void OneTimeBigIcon()
 {
     LocalNotification.SendNotification(1, 5000, "Title", "Long message text with big icon", new Color32(0xff, 0x44, 0x44, 255), true, true, true, "app_icon");
 }
Example #42
0
        //private
        private void SetNotificationsEnabled(bool enabled, bool inInitialization)
        {
            UnityEngine.PlayerPrefs.SetInt(m_enabledOptionName, enabled ? 1 : 0);

            if (!inInitialization && !Initialized)
            {
                if (!enabled)
                {
                    NotificationServices.UnregisterForRemoteNotifications();
                }

                return;
            }

            if (m_enabled == enabled)
            {
                return;
            }

            m_enabled = enabled;

            if (enabled)
            {
                RegisterForNotifications();

                if (m_scheduledNotificationsWhenDisabled != null)
                {
                    DateTime now = DateTime.Now;

                    foreach (var scheduledNotification in m_scheduledNotificationsWhenDisabled)
                    {
                        LocalNotification notification = new LocalNotification();
                        if (scheduledNotification.badgeNumber >= 0)
                        {
                            notification.applicationIconBadgeNumber = scheduledNotification.badgeNumber;
                        }
                        notification.alertAction = scheduledNotification.alertAction;
                        notification.alertBody   = scheduledNotification.alertBody;
                        notification.hasAction   = true;
                        notification.soundName   = scheduledNotification.soundName;
                        notification.userInfo    = (scheduledNotification.userData != null) ? scheduledNotification.userData : new Dictionary <string, string>();
                        if (scheduledNotification.fireDate > now)
                        {
                            notification.fireDate = scheduledNotification.fireDate;
                        }
                        else if (scheduledNotification.fireDate != DateTime.MinValue)
                        {
                            notification.fireDate = DateTime.Now.AddSeconds(2);
                        }
                        else
                        {
                            notification.fireDate = RepeatIntervalToDateTime(scheduledNotification.repeatInterval);
                        }
                        notification.repeatInterval = scheduledNotification.repeatInterval;

                        NotificationServices.ScheduleLocalNotification(notification);
                    }

                    m_scheduledNotificationsWhenDisabled = null;
                    SaveScheduledNotificationsWhenDisabled();
                }

                if (!inInitialization)
                {
                    SetBadge(GetBadge());
                }
            }
            else
            {
                List <ScheduledNotification> scheduledNotificationsWhenDisabled;
                if (NotificationServices.scheduledLocalNotifications != null && NotificationServices.scheduledLocalNotifications.Length != 0)
                {
                    scheduledNotificationsWhenDisabled = new List <ScheduledNotification>(NotificationServices.scheduledLocalNotifications.Length);

                    DateTime now = DateTime.Now;

                    foreach (var notification in NotificationServices.scheduledLocalNotifications)
                    {
                        scheduledNotificationsWhenDisabled.Add(ToScheduledNotification(notification, now));
                    }
                }
                else
                {
                    scheduledNotificationsWhenDisabled = null;
                }

                CancelAllNotifications();
                NotificationServices.UnregisterForRemoteNotifications();

                if (scheduledNotificationsWhenDisabled != null)
                {
                    m_scheduledNotificationsWhenDisabled = scheduledNotificationsWhenDisabled;
                    SaveScheduledNotificationsWhenDisabled();
                }

                _UT_SetIconBadgeNumber(0);
            }
        }