ClearLocalNotifications() private méthode

private ClearLocalNotifications ( ) : void
Résultat void
        private void Update()
        {
            // no point checking if we don't have a device token yet
            if (this.deviceToken == null)
            {
                return;
            }

            this.currentQueryTime += Time.deltaTime;

            // early out if haven't met the query time
            if (this.currentQueryTime < QueryTimerMax)
            {
                return;
            }

            // reset timer
            this.currentQueryTime = 0.0f;

            // https://forum.unity3d.com/threads/using-the-new-notification-system.127016/
            if (NotificationServices.remoteNotificationCount != 0)
            {
                // iterating over all the remote notifications
                for (int i = 0; i < NotificationServices.remoteNotificationCount; i++)
                {
                    this.pushHandler.ReceivedPushNotification(NotificationServices.GetRemoteNotification(i).alertBody);
                }

                // clear all messages
                NotificationServices.ClearRemoteNotifications();
                NotificationServices.ClearLocalNotifications();
            }
        }
Exemple #2
0
    private void cancelNotification()
    {
        NotificationManager.CancelAll();
        //LocalNotification.ClearNotifications();
#if UNITY_IOS
        NotificationServices.CancelAllLocalNotifications();
        NotificationServices.ClearLocalNotifications();
#endif
    }
Exemple #3
0
 public void ClearNotification()
 {
     #if UNITY_IOS
     LocalNotification l = new LocalNotification();
     l.applicationIconBadgeNumber = -1;
     NotificationServices.PresentLocalNotificationNow(l);
     NotificationServices.CancelAllLocalNotifications();
     NotificationServices.ClearLocalNotifications();
     #endif
 }
 /// <summary>
 /// Uklanja sve setovane  lokalne notifikacije (Samo IOS)
 /// </summary>
 public void CancelAllNotifications()
 {
             #if UNITY_IOS && !UNITY_EDITOR
     //Empty notification to clear badge number
     LocalNotification l = new LocalNotification();
     l.applicationIconBadgeNumber = -1;
     NotificationServices.PresentLocalNotificationNow(l);
     NotificationServices.CancelAllLocalNotifications();
     NotificationServices.ClearLocalNotifications();
     NotificationServices.ClearLocalNotifications();
             #endif
 }
    public static void ClearNotification()
    {
                #if UNITY_IOS
        mIconBadgeNumber = 0;
        CancelAllLocalNotifications();
        ClearLocalNotifications();

        LocalNotification localNotification = new LocalNotification();
        localNotification.applicationIconBadgeNumber = -1;
        NotificationServices.PresentLocalNotificationNow(localNotification);
        NotificationServices.CancelAllLocalNotifications();
        NotificationServices.ClearLocalNotifications();
                #endif
    }
        // Call by main game OnApplicationPause
        public void ClearAllNotifications()
        {
#if UNITY_ANDROID
            NotificationManager.CancelAll();
#elif UNITY_IOS
            if (NotificationServices.localNotificationCount > 0)
            {
                //foreach (LocalNotification notification in NotificationServices.localNotifications)
                //{
                //    Debug.Log("INCOME ALERTS: " + notification.alertBody);
                //}
            }

            // cancel all notifications first.
            NotificationServices.CancelAllLocalNotifications();
            NotificationServices.ClearLocalNotifications();
#endif
        }
        private void ClearNotify()
        {
            if (0 < NotificationServices.localNotificationCount)
            {
                var localNotification = new LocalNotification();

                localNotification.applicationIconBadgeNumber = -1;

                NotificationServices.PresentLocalNotificationNow(localNotification);
            }

            if (NotificationServices.scheduledLocalNotifications.Any())
            {
                NotificationServices.CancelAllLocalNotifications();

                NotificationServices.ClearLocalNotifications();
            }
        }
Exemple #8
0
    void Update()
    {
        if (Time.time > 2 && auctionwait == false)
        {
            auctionopen = true;
        }
        //check pre-auction wait is over or not
        if (auctionwait == true && (Time.time - auctiontime) > 10)
        {
            auctionend = true;
        }
        //check auction is over or not
        if (NotificationServices.localNotificationCount > 0)
        {
            Debug.Log(NotificationServices.localNotifications[0].alertBody);
            NotificationServices.ClearLocalNotifications();
        }
        //push iOS notifications
        if ((Time.time / 60) % 5 == 0)
        {
            var notif = new LocalNotification();
            notif.fireDate = System.DateTime.Now.AddSeconds(0);
            var rad = (int)Random.Range(0, 9);
            switch (rad)
            {
            case 0:
                randomnewstext = "NewsTexts0";
                break;

            case 1:
                randomnewstext = "NewsTexts1";
                break;

            case 2:
                randomnewstext = "NewsTexts2";
                break;

            case 3:
                randomnewstext = "NewsTexts3";
                break;

            case 4:
                randomnewstext = "NewsTexts4";
                break;

            case 5:
                randomnewstext = "NewsTexts5";
                break;

            case 6:
                randomnewstext = "NewsTexts6";
                break;

            case 7:
                randomnewstext = "NewsTexts7";
                break;

            case 8:
                randomnewstext = "NewsTexts8";
                break;

            case 9:
                randomnewstext = "NewsTexts9";
                break;
            }
            notif.alertBody = randomnewstext;
            NotificationServices.ScheduleLocalNotification(notif);
            // random news event iOS notification to be delivered for every 5 minutes
        }
    }
    /// <summary>
    /// Local recurring notification. Recurring weekly once you havent touched the app in more than 7 days
    /// Also populates rate app notification
    /// </summary>
    public void ScheduleLocalNotification()
    {
                #if UNITY_IOS
        // Reset the badge icon
        UnityEngine.iOS.LocalNotification resetNotif = new UnityEngine.iOS.LocalNotification();
        resetNotif.applicationIconBadgeNumber = -1;
        resetNotif.hasAction = false;
        NotificationServices.PresentLocalNotificationNow(resetNotif);

        // Clear and cancel
        NotificationServices.ClearLocalNotifications();                                                            // Clear all received notifications
        foreach (UnityEngine.iOS.LocalNotification localNotif in NotificationServices.scheduledLocalNotifications) // Remove reminder notifications
        {
            if (localNotif.repeatInterval == UnityEngine.iOS.CalendarUnit.Week)
            {
                NotificationServices.CancelLocalNotification(localNotif);
                Debug.Log("CANCELLING RECURRING NOTIFICATIONS");
            }
        }

        // Prepare to fire new notification
        string iOSAction = "visit " + DataManager.Instance.GameData.PetInfo.PetName;            // Action (ie. slide to _)
        string iOSBody   = DataManager.Instance.GameData.PetInfo.PetName + " misses you!";

        DateTime fireDate = LgDateTime.GetTimeNow().AddDays(7);                 // Schedule for 7 days from now

        UnityEngine.iOS.LocalNotification notif = new UnityEngine.iOS.LocalNotification();
        notif.fireDate                   = fireDate;
        notif.alertAction                = iOSAction;
        notif.alertBody                  = iOSBody;
        notif.soundName                  = UnityEngine.iOS.LocalNotification.defaultSoundName;
        notif.repeatInterval             = UnityEngine.iOS.CalendarUnit.Week;
        notif.applicationIconBadgeNumber = -1;
        NotificationServices.ScheduleLocalNotification(notif);


        // Also check if we need to push the rate app notification
        // Conditions - passed day 7 retention, only seen once
        TimeSpan difference = LgDateTime.GetTimeNow().Subtract(DataManager.Instance.GameData.PlayPeriod.FirstPlayPeriod);
        if (!DataManager.Instance.GameData.PlayPeriod.IsDisplayedAppNotification &&                     // Displayed for first time
            DataManager.Instance.GameData.PlayPeriod.IsFirstPlayPeriodAux &&                            // Started first play session in
            difference > new TimeSpan(7, 0, 0, 0))                                                      // Past 7 days

        {
            UnityEngine.iOS.LocalNotification rateNotif = new UnityEngine.iOS.LocalNotification();

            // Shoot for next 8:47am
            DateTime now        = LgDateTime.GetTimeNow();
            DateTime today847am = now.Date.AddHours(8).AddMinutes(47);
            DateTime next847am  = now <= today847am ? today847am : today847am.AddDays(1);

            rateNotif.fireDate    = next847am;
            rateNotif.alertAction = "open game";
            rateNotif.alertBody   = "Is 'Wizdy Pets' helping your kids with asthma? Leave us a review in the AppStore!";
            rateNotif.soundName   = UnityEngine.iOS.LocalNotification.defaultSoundName;
            rateNotif.applicationIconBadgeNumber = -1;

            NotificationServices.ScheduleLocalNotification(rateNotif);
            DataManager.Instance.GameData.PlayPeriod.IsDisplayedAppNotification = true;
        }
#endif

#if UNITY_ANDROID && !UNITY_EDITOR
        string title = DataManager.Instance.GameData.PetInfo.PetName + " misses you!";
        string body  = "Why not stop by and visit?";

        AndroidNotifications.cancelNotification(1);
        int id = 1;
        NotificationBuilder build    = new NotificationBuilder(id, title, body);
        TimeSpan            interval = new TimeSpan(168, 0, 0);
        build.setInterval(interval);
        build.setAutoCancel(false);
        build.setDelay(interval);
        AndroidNotifications.scheduleNotification(build.build());
#endif
    }
Exemple #10
0
 public void ClearIOSNotifications()
 {
     Notification.ClearLocalNotifications();
 }
Exemple #11
0
    // Use this for initialization
    void Start()
    {
                #if UNITY_IOS
        NotificationServices.ClearLocalNotifications();                         // 受信したローカル通知を削除
                #endif

        GameObject obj = GameObject.Find("SoundMaster");
        if (obj != null)
        {
            SoundMaster script = obj.GetComponent <SoundMaster> ();
            if (script.BGMSource.isPlaying.Equals(false))
            {
                script.PlayBGM();
            }
        }

        SDM = GetComponent <SaveDataManager>();  // SaveDataManager

        ls = new List <strData>();

        current = new DateTime(DateTime.Today.Year, DateTime.Today.Month, DateTime.Today.Day);



        InitCalendarComponent();

        SetCalendar();



        if (nextButton != null)

        {
            //押されたら起動

            nextButton.onClick.AsObservable()

            .Subscribe(_ =>

            {
                //一つ月を進める

                current = current.AddMonths(1);

                SetCalendar();
            });
        }

        if (prevButton != null)

        {
            prevButton.onClick.AsObservable()

            .Subscribe(_ =>

            {
                current = current.AddMonths(-1);

                SetCalendar();
            });
        }

        // Reviewモードボタン描画処理

        // 復習問題データを更新
        // このReviewMargeがどうやらやたら重い。
        // どうせ1日1回だけの処理なので1回だけしか行われないようにすればよい
        // 方法としてはせーぶデータを使う方法
        // DailyCheckと銘打ち
        // 今日の日付、結果を保持
        // ex 20190701F またはT
        // Debug
        // PlayerPrefs.SetString("DailyCheck", "19890207F");
        string str      = PlayerPrefs.GetString("DailyCheck", "19890207F"); // デイリーチェックの最終実施日をロード
        bool   flg      = false;                                            // 今日実施できる復習問題の有無フラグ
        string strToday = Common.GetDate();
        if (Common.Left(str, 8) == strToday)
        {                                    // 今日のものであれば
            if (Common.Right(str, 1) == "T") // 有りと判定がすでに出ていれば
            {
                if (PlayerPrefs.GetString("RevWholeMiss", "") != "")
                {
                    flg = true; // 復習モードを解放
                }
            }
            else
            {
                PlayerPrefs.SetString("DailyCheck", strToday + "F");   // デイリーチェックの最終実施日を更新
            }
        }
        else
        if (ReviewMerge() == true)
        {                                                        // 今日実施分があれば
            flg = true;                                          // 復習モードを解放
            PlayerPrefs.SetString("DailyCheck", strToday + "T"); // デイリーチェックの最終実施日を更新
        }
        else
        {
            PlayerPrefs.SetString("DailyCheck", strToday + "F");   // デイリーチェックの最終実施日を更新
        }
        if (flg == false)
        {
            obj = GameObject.Find("DCMain_reviewButton");
            Text txt = obj.transform.Find("Text").GetComponent <Text>();
            txt.text     = "復習モード" + System.Environment.NewLine + "本日の問題はありません";
            txt.fontSize = 32;
            obj.GetComponent <Button>().interactable = false;
            obj.GetComponent <Image>().color         = new Color(93.0f / 255.0f, 93.0f / 255.0f, 93.0f / 255.0f, 120.0f / 255.0f);
            // ボタンの色を変える
        }
    }
Exemple #12
0
 public void ClearLocalNotification()
 {
             #if UNITY_IOS
     NotificationServices.ClearLocalNotifications();
             #endif
 }