예제 #1
0
    public void NotificationExample(string title, string body, int afterTime)
    {
        var timeTrigger = new iOSNotificationTimeIntervalTrigger()
        {
            TimeInterval = new TimeSpan(0, 0, afterTime),
            Repeats      = false
        };

        iOSNotification notification = new iOSNotification()
        {
            // You can optionally specify a custom identifier which can later be
            // used to cancel the notification, if you don't set one, a unique
            // string will be generated automatically.
            Identifier                   = "_notification_01",
            Title                        = title,
            Body                         = body,
            Subtitle                     = "This is a subtitle, something, something important...",
            ShowInForeground             = false,
            ForegroundPresentationOption = (PresentationOption.Alert | PresentationOption.Sound),
            CategoryIdentifier           = "category_a",
            ThreadIdentifier             = "thread1",
            Trigger                      = timeTrigger,
        };

        iOSNotificationCenter.ScheduleNotification(notification);
    }
예제 #2
0
    public static void createNotification(string title, string body, string subtitle)
    {
        #if UNITY_IPHONE
        var timeTrigger = new iOSNotificationTimeIntervalTrigger()
        {
            TimeInterval = new TimeSpan(0, 0, 1),
            Repeats      = false
        };

        var notification = new iOSNotification()
        {
            // You can specify a custom identifier which can be used to manage the notification later.
            // If you don't provide one, a unique string will be generated automatically.
            Identifier                   = "_notification_01",
            Title                        = title,
            Body                         = body,
            Subtitle                     = subtitle,
            ShowInForeground             = true,
            ForegroundPresentationOption = (PresentationOption.Alert | PresentationOption.Sound),
            CategoryIdentifier           = "category_a",
            ThreadIdentifier             = "thread1",
            Trigger                      = timeTrigger,
        };

        iOSNotificationCenter.ScheduleNotification(notification);
        #elif UNITY_ANDROID
        var notification = new AndroidNotification();
        notification.Title    = title;
        notification.Text     = subtitle;
        notification.FireTime = System.DateTime.Now;

        AndroidNotificationCenter.SendNotification(notification, "channel_id");
        #endif
    }
    public IEnumerator SendSimpleNotification_NotificationIsReceived()
    {
        var timeTrigger = new iOSNotificationTimeIntervalTrigger()
        {
            TimeInterval = new TimeSpan(0, 0, 5),
            Repeats      = false
        };

        // You can optionally specify a custom Identifier which can later be
        // used to cancel the notification, if you don't set one, an unique
        // string will be generated automatically.
        var notification = new iOSNotification()
        {
            Identifier                   = "_notification_01",
            Title                        = "SendSimpleNotification_NotificationIsReceived",
            Body                         = "Scheduled at: " + DateTime.Now.ToShortDateString() + " triggered in 5 seconds",
            Subtitle                     = "This is a subtitle, something, something important...",
            ShowInForeground             = true,
            ForegroundPresentationOption = (PresentationOption.Alert |
                                            PresentationOption.Sound),
            CategoryIdentifier = "category_a",
            ThreadIdentifier   = "thread1",
            Trigger            = timeTrigger,
        };

        iOSNotificationCenter.ScheduleNotification(notification);

        yield return(WaitForNotification(10.0f));

        Assert.AreEqual(1, receivedNotificationCount);
    }
    public IEnumerator SendNotificationWithUserInfo_NotificationIsReceivedWithSameUserInfo()
    {
        var timeTrigger = new iOSNotificationTimeIntervalTrigger()
        {
            TimeInterval = new TimeSpan(0, 0, 5),
            Repeats      = false
        };

        var notification = new iOSNotification()
        {
            Identifier                   = "_notification_02",
            Title                        = "SendNotificationWithUserInfo_NotificationIsReceivedWithSameUserInfo",
            Body                         = "Scheduled at: " + DateTime.Now.ToShortDateString() + " triggered in 5 seconds",
            Subtitle                     = "This is a subtitle, something, something important...",
            ShowInForeground             = true,
            ForegroundPresentationOption = PresentationOption.Alert | PresentationOption.Sound,
            CategoryIdentifier           = "category_a",
            ThreadIdentifier             = "thread1",
            Trigger                      = timeTrigger,
        };

        notification.UserInfo.Add("key1", "value1");

        iOSNotificationCenter.ScheduleNotification(notification);

        yield return(WaitForNotification(10.0f));

        Assert.AreEqual(1, receivedNotificationCount);
        Assert.IsNotNull(lastReceivedNotification);
        Assert.IsTrue(lastReceivedNotification.UserInfo.ContainsKey("key1"));
        Assert.AreEqual("value1", lastReceivedNotification.UserInfo["key1"]);
    }
예제 #5
0
    //Send Simple Notification
    string SendSimpleNotification4Seconds(string title = "SendSimpleNotification4Seconds", string thread = "thread_1", bool repeat = false, int seconds = 4, int minutes = 0, PresentationOption foregroundOption = PresentationOption.Alert, int badge = -1)
    {
        Debug.Log("SendSimpleNotification4Seconds");
        var timeTrigger = new iOSNotificationTimeIntervalTrigger()
        {
            TimeInterval = new TimeSpan(0, minutes, seconds),
            Repeats      = repeat
        };

        iOSNotification n = new iOSNotification()
        {
            Title                        = title,
            Body                         = "Scheduled at: " + DateTime.Now.ToShortDateString() + " triggered in 5 seconds",
            Subtitle                     = "This is a subtitle, something, something important...",
            ShowInForeground             = true,
            ForegroundPresentationOption = foregroundOption,
            CategoryIdentifier           = "category_a",
            ThreadIdentifier             = thread,
            Trigger                      = timeTrigger,
            Data                         = "data_SendSimpleNotification4Seconds",
        };

        /* if (badge >= 0)
         *  n.Badge = badge + 1;*/

        iOSNotificationCenter.ScheduleNotification(n);

        return(n.Identifier);
    }
예제 #6
0
        private string IosNotify(int delay, string title, string subtitle, String body)
        {
            var timeTrigger = new iOSNotificationTimeIntervalTrigger()
            {
                TimeInterval = new TimeSpan(0, 0, delayValue),
                Repeats      = false
            };

            var notification = new iOSNotification()
            {
                // You can specify a custom identifier which can be used to manage the notification later.
                // If you don't provide one, a unique string will be generated automatically.

                Title                        = title,
                Body                         = body,
                Subtitle                     = subtitle,
                ShowInForeground             = true,
                ForegroundPresentationOption = (PresentationOption.Alert | PresentationOption.Sound),
                CategoryIdentifier           = "category_a",
                ThreadIdentifier             = "thread1",
                Trigger                      = timeTrigger,
            };

            iOSNotificationCenter.ScheduleNotification(notification);
            return(notification.Identifier);
        }
예제 #7
0
    private void Start()
    {
        iOSNotificationTimeIntervalTrigger timeTrigger = new iOSNotificationTimeIntervalTrigger()
        {
            TimeInterval = new TimeSpan(0, 0, 10),
            Repeats      = false,
        };

        iOSNotificationCalendarTrigger calendarTrigger = new iOSNotificationCalendarTrigger()
        {
            // Year = 2019,
            // Month = 8,
            //Day = 30,
            Hour   = 12,
            Minute = 0,
            // Second = 0
            Repeats = false
        };

        iOSNotificationLocationTrigger locationTrigger = new iOSNotificationLocationTrigger()
        {
            Center        = new Vector2(2.294498f, 48.858263f),
            Radius        = 250f,
            NotifyOnEntry = true,
            NotifyOnExit  = false,
        };

        iOSNotification notification = new iOSNotification()
        {
            Identifier                   = "test_notification",
            Title                        = "Test Notification!",
            Subtitle                     = "A Unity Royale Test Notification",
            Body                         = "This is a test notification!",
            ShowInForeground             = true,
            ForegroundPresentationOption = (PresentationOption.Alert | PresentationOption.Sound),
            CategoryIdentifier           = "category_a",
            ThreadIdentifier             = "thread1",
            Trigger                      = timeTrigger,
        };

        iOSNotificationCenter.ScheduleNotification(notification);

        iOSNotificationCenter.OnRemoteNotificationReceived += recievedNotification =>
        {
            Debug.Log("Recieved notification " + notification.Identifier + "!");
        };


        iOSNotification notificationIntentData = iOSNotificationCenter.GetLastRespondedNotification();

        if (notificationIntentData != null)
        {
            Debug.Log("App was opened with notification!");
        }
    }
예제 #8
0
        public void SetupFullEnergyNotification(int hours, int minutes, int seconds)
        {
            if (_isPushNotificationsEnable == false)
            {
                return;
            }

#if UNITY_IOS
            iOSNotificationCenter.RemoveScheduledNotification(_fullEnergyNotificationID);
            iOSNotificationTimeIntervalTrigger timeTrigger = new iOSNotificationTimeIntervalTrigger()
            {
                TimeInterval = new TimeSpan(hours, minutes, seconds),
                Repeats      = false
            };

            iOSNotification notification = new iOSNotification()
            {
                Identifier                   = _fullEnergyNotificationID,
                Title                        = SimpleLocalization.LocalizationManager.Localize("PrPol.FullEnT"),
                Body                         = SimpleLocalization.LocalizationManager.Localize("PrPol.FullEnD"),
                ShowInForeground             = true,
                ForegroundPresentationOption = PresentationOption.Alert | PresentationOption.Sound,
                Trigger                      = timeTrigger,
            };

            iOSNotificationCenter.ScheduleNotification(notification);
#endif

#if UNITY_ANDROID
            AndroidNotificationCenter.DeleteNotificationChannel(_fullEnergyNotificationID);
            AndroidNotificationCenter.CancelScheduledNotification(_energyNotification);
            AndroidNotificationChannel anc = new AndroidNotificationChannel()
            {
                Id          = _fullEnergyNotificationID,
                Name        = "fullenergyNotification",
                Importance  = Importance.High,
                Description = "Generic notifications",
            };

            AndroidNotificationCenter.RegisterNotificationChannel(anc);

            AndroidNotification notification = new AndroidNotification
            {
                Title     = SimpleLocalization.LocalizationManager.Localize("PrPol.FullEnT"),
                Text      = SimpleLocalization.LocalizationManager.Localize("PrPol.FullEnD"),
                FireTime  = DateTime.Now.Add(new TimeSpan(hours, minutes, seconds)),
                SmallIcon = "daily_reward_icon_small",
                LargeIcon = "daily_reward_icon_large"
            };

            _energyNotification = AndroidNotificationCenter.SendNotification(notification, _fullEnergyNotificationID);
#endif
        }
        /// <summary>
        /// Schedules a notification
        /// </summary>
        /// <param name="title">title of the notification</param>
        /// <param name="text">body of the notification</param>
        /// <param name="timeDelayFromNow">time to appear, calculated from now</param>
        /// <param name="smallIcon">small icon name for android only - from Mobile Notification Settings </param>
        /// <param name="largeIcon">large icon name for android only - from Mobile Notification Settings </param>
        /// <param name="customData">custom data that can be retrieved when user opens the app from notification </param>
        internal void SendNotification(string title, string text, TimeSpan timeDelayFromNow, string smallIcon, string largeIcon, string customData)
        {
#if EnableNotificationsAndroid
            var notification = new AndroidNotification();
            notification.Title = title;
            notification.Text  = text;
            if (smallIcon != null)
            {
                notification.SmallIcon = smallIcon;
            }
            if (smallIcon != null)
            {
                notification.LargeIcon = largeIcon;
            }
            if (customData != null)
            {
                notification.IntentData = customData;
            }
            notification.FireTime = DateTime.Now.Add(timeDelayFromNow);

            AndroidNotificationCenter.SendNotification(notification, channelID + count);
#endif

#if EnableNotificationsIos
            print("I am Notification Manager");
            iOSNotificationTimeIntervalTrigger timeTrigger = new iOSNotificationTimeIntervalTrigger()
            {
                TimeInterval = timeDelayFromNow,
                Repeats      = false,
            };

            iOSNotification notification = new iOSNotification()
            {
                Identifier                   = channelID + count,
                Title                        = title,
                Subtitle                     = "Time To Meditate",
                Body                         = text,
                Data                         = customData,
                ShowInForeground             = true,
                ForegroundPresentationOption = (PresentationOption.Alert | PresentationOption.Sound),
                CategoryIdentifier           = "category_a",
                ThreadIdentifier             = "thread1",
                Trigger                      = timeTrigger,
            };
            if (AlarmClockMenuEventListerner.instance.newAlarm)
            {
                AlarmClockMenuEventListerner.instance.ChannelId.Add(notification.Identifier);
                count++;
            }
            iOSNotificationCenter.ScheduleNotification(notification);
#endif
        }
        public void TimeIntervalTrigger_MeasuredInSeconds()
        {
            var trigger = new iOSNotificationTimeIntervalTrigger();
            var interval = TimeSpan.FromMinutes(1);
            trigger.TimeInterval = interval;
            Assert.AreEqual(60, trigger.timeInterval);
            var outInterval = trigger.TimeInterval;
            Assert.AreEqual(interval, outInterval);

            trigger.TimeInterval = new TimeSpan(0, 0, 1, 5, 50);
            // milliseconds should get discarded
            Assert.AreEqual(65, trigger.timeInterval);
        }
 void CheckTimeSpanIsRected(TimeSpan interval)
 {
     try
     {
         var trigger = new iOSNotificationTimeIntervalTrigger();
         trigger.TimeInterval = interval;
         Assert.Fail("Exception expected");
     }
     catch (ArgumentException)
     {
         // expected
     }
 }
    /// <summary>
    /// iOSの通知を送信する。
    /// </summary>
    /// <param name="title">タイトル。</param>
    /// <param name="detail">詳細。</param>
    /// <param name="notificationTimeInterval">通知までの時間。</param>
    /// <param name="identifier">識別子。</param>
    /// <param name="isRepeat">通知を繰り返すか。</param>
    static public void SendIOSNotification(string title, string detail, TimeSpan notificationTimeInterval, string identifier, bool isRepeat = false)
    {
        // すでにスケジュール登録されている通知であれば削除する。
        CancelIOSNotificationIfScheduled(identifier);

        // 通知を作成。
        var notification = CreateCommonNotification(title, detail, identifier);

        // 通知時間を設定。
        var timeTrigger = new iOSNotificationTimeIntervalTrigger();

        timeTrigger.TimeInterval = notificationTimeInterval;
        timeTrigger.Repeats      = isRepeat;
        notification.Trigger     = timeTrigger;

        // 通知を送信。
        iOSNotificationCenter.ScheduleNotification(notification);
    }
예제 #13
0
        public void scheduleLocalNotification(LocalNotificationData notificationData)
        {
            if (!isInitialized)
            {
                return;
            }
            var timeSpan    = TimeExtensions.hoursToTimeSpan(notificationData.triggerInHours);
            var timeTrigger = new iOSNotificationTimeIntervalTrigger()
            {
                TimeInterval = timeSpan,
                Repeats      = notificationData.isRepeatingNotification
            };

            notificationData.utcScheduledTime = TimeExtensions.currentUtcTime.Add(timeSpan);
            iOSNotification notification = createNotification(notificationData, timeTrigger);

            iOSNotificationCenter.ScheduleNotification(notification);
        }
예제 #14
0
    public void InterceptAllReceivedRemoteNotifications()
    {
        iOSNotificationCenter.OnRemoteNotificationReceived += notification =>
        {
            Debug.Log("Just got a remote notification will reschedule it locally in 3 seconds!");

            var msg = "Just got a remote notification will reschedule it locally in 3 seconds! \n it's data and id:" + notification.Identifier + "\n";
            msg += "\n Notification received: ";
            msg += "\n .Title: " + notification.Title;
            msg += "\n .Badge: " + notification.Badge;
            msg += "\n .Body: " + notification.Body;
            msg += "\n .CategoryIdentifier: " + notification.CategoryIdentifier;
            msg += "\n .Subtitle: " + notification.Subtitle;
            msg += "\n ------ \n\n";
            Debug.Log(msg);


            var timeTrigger = new iOSNotificationTimeIntervalTrigger()
            {
                TimeInterval = new TimeSpan(0, 0, 3),
                Repeats      = false
            };

            iOSNotification n = new iOSNotification()
            {
                Title                        = "RE : " + notification.Title,
                Body                         = "RE : " + notification.Body,
                Subtitle                     = "RE : " + notification.Subtitle,
                ShowInForeground             = true,
                ForegroundPresentationOption = PresentationOption.Sound | PresentationOption.Alert | PresentationOption.Badge,
                CategoryIdentifier           = notification.CategoryIdentifier,
                ThreadIdentifier             = notification.ThreadIdentifier,
                Trigger                      = timeTrigger,
                Badge                        = notification.Badge,
            };

            iOSNotificationCenter.ScheduleNotification(n);

            Debug.Log("Rescheduled remote notifications with id: " + notification.Identifier);
        };
    }
예제 #15
0
        public void SendSpinWheelNotification()
        {
            // dotázat se na zapnutí notifikací - jestli je má, a když ne, tak vyvolat request
            RequestRegistreNotifications();


            // ověřit, zda je nějaká notifikace aktivní, případně ji vypnout
            CheckScheduledSpinNotification();

            // poslat novou notifikaci

            #region iOS

#if UNITY_IOS
            iOSNotificationTimeIntervalTrigger trigger = new iOSNotificationTimeIntervalTrigger()
            {
                TimeInterval =
                    new TimeSpan(0, RemoteSettingsData.Instance.spinWheelSettingsData.CountDownHours, RemoteSettingsData.Instance.spinWheelSettingsData.CountDownMinutes, RemoteSettingsData.Instance.spinWheelSettingsData.CountDownSeconds),
                Repeats = false
            };

            notificationSpin = new iOSNotification()
            {
                Identifier                   = "notification_spin",
                Title                        = "Spin Wheel is ready!",
                Body                         = "Try your luck and get awsome reward!",
                Subtitle                     = "",
                ShowInForeground             = true,
                ForegroundPresentationOption = (PresentationOption.Alert | PresentationOption.Sound),
                CategoryIdentifier           = "spin_wheel",
                ThreadIdentifier             = "thread1",
                Trigger                      = trigger,
            };

            Debug.Log("Sendikng Notification iOS");
            iOSNotificationCenter.ScheduleNotification(notificationSpin);
#endif

            #endregion
        }
예제 #16
0
        private void ScheduleNotificationImpl(Notification notification)
        {
            Log.Debug("ScheduleNotificationImpl");

            if (!Enabled)
            {
                Log.Debug("Notifications disabled.");
                return;
            }

            if (!Authorized)
            {
                Log.Warn("Notifications not authorized.");
                return;
            }

            var timeTrigger = new iOSNotificationTimeIntervalTrigger
            {
                TimeInterval = new TimeSpan(0, 0, notification.TimeoutSeconds),
                Repeats      = false
            };

            var iOSNotification = new iOSNotification
            {
                Identifier = notification.idString,

                Title    = notification.title,
                Subtitle = notification.subTitle,
                Body     = notification.text,

                ShowInForeground             = true,
                ForegroundPresentationOption = PresentationOption.Alert | PresentationOption.Badge | PresentationOption.Sound,
                Badge = 1,
                CategoryIdentifier = "default_category",
                ThreadIdentifier   = "default_thread",
                Trigger            = timeTrigger
            };

            iOSNotificationCenter.ScheduleNotification(iOSNotification);
        }
예제 #17
0
    void SendSimpleNotification4SecondsNoTitleWithBody()
    {
        var timeTrigger = new iOSNotificationTimeIntervalTrigger()
        {
            TimeInterval = new TimeSpan(0, 0, 5),
            Repeats      = false
        };

        iOSNotification n = new iOSNotification()
        {
//          Title = title,
            Body                         = "Scheduled at: " + DateTime.Now.ToShortDateString() + " triggered in 5 seconds",
            Subtitle                     = "This is a subtitle, something, something important...",
            ShowInForeground             = true,
            ForegroundPresentationOption = PresentationOption.Sound | PresentationOption.Alert,
//          CategoryIdentifier = "category_a",
//          ThreadIdentifier = thread,
            Trigger = timeTrigger,
        };

        iOSNotificationCenter.ScheduleNotification(n);
    }
예제 #18
0
    private void schaduleIosNotification(string title, string content, TimeSpan timeSpan)
    {
        var timeTrigger = new iOSNotificationTimeIntervalTrigger()
        {
            TimeInterval = timeSpan,
            Repeats      = false
        };
        var notification = new iOSNotification()
        {
            // You can specify a custom identifier which can be used to manage the notification later.
            // If you don't provide one, a unique string will be generated automatically.
            //Identifier = "_notification_01",
            Title = title,
            Body  = content,
            //Subtitle = "This is a subtitle, something, something important...",
            ShowInForeground             = true,
            ForegroundPresentationOption = (PresentationOption.Alert | PresentationOption.Sound),
            //CategoryIdentifier = "category_a",
            //ThreadIdentifier = "thread1",
            Trigger = timeTrigger,
        };

        iOSNotificationCenter.ScheduleNotification(notification);
    }
예제 #19
0
    public void CreateIosNotification(System.TimeSpan span)
    {
        var _time = new iOSNotificationTimeIntervalTrigger()
        {
            TimeInterval = span,
            Repeats      = false
        };


        _notification n = GetRandomNotification();

        var _notification = new iOSNotification()
        {
            Title                        = n._Header,
            Body                         = n._Message,
            ShowInForeground             = true,
            ForegroundPresentationOption = (PresentationOption.Alert | PresentationOption.Sound),
            CategoryIdentifier           = "simple_category",
            ThreadIdentifier             = "instajong_thread",
            Trigger                      = _time
        };

        iOSNotificationCenter.ScheduleNotification(_notification);
    }
예제 #20
0
        private static iOSNotification createNotification(LocalNotificationData notificationData, iOSNotificationTimeIntervalTrigger timeTrigger)
        {
            var notification = new iOSNotification()
            {
                // You can optionally specify a custom Identifier which can later be
                // used to cancel the notification, if you don't set one, an unique
                // string will be generated automatically.
                Identifier                   = notificationData.id.ToString(),
                Title                        = notificationData.title,
                Body                         = notificationData.text,
                Subtitle                     = "",
                ShowInForeground             = true,
                ForegroundPresentationOption = PresentationOption.NotificationPresentationOptionAlert,
                CategoryIdentifier           = Application.productName,
                //ThreadIdentifier = thread,
                Trigger = timeTrigger,
            };

            return(notification);
        }
    private void OnApplicationPause(bool gameStatus)
    {
        if (gameStatus)//set notification when app goes to background
        {
#if UNITY_ANDROID
            string channel = "missyouchannel";
            var    c       = new AndroidNotificationChannel()
            {
                Id          = channel,
                Name        = "Default Channel",
                Importance  = Importance.High,
                Description = "Generic notifications",
            };
            AndroidNotificationCenter.RegisterNotificationChannel(c);
            var notification = new AndroidNotification();
            notification.Title    = "";
            notification.Text     = "";
            notification.FireTime = DateTime.Now.AddDays(3);


            AndroidNotificationCenter.SendNotification(notification, channel);

            var dailyNotification = new AndroidNotification();
            dailyNotification.Title    = "";
            dailyNotification.Text     = "";
            dailyNotification.FireTime = DateTime.Now.AddDays(1);



            AndroidNotificationCenter.SendNotification(dailyNotification, channel);
#elif UNITY_IOS
            var timeTrigger = new iOSNotificationTimeIntervalTrigger()
            {
                TimeInterval = new TimeSpan(72, 0, 0),
                Repeats      = false
            };

            var dailyTimeTrigger = new iOSNotificationTimeIntervalTrigger()
            {
                TimeInterval = new TimeSpan(24, 0, 0),
                Repeats      = false
            };

            var notificationIOS = new iOSNotification()
            {
                // You can optionally specify a custom identifier which can later be
                // used to cancel the notification, if you don't set one, a unique
                // string will be generated automatically.
                Identifier                   = "three_day",
                Title                        = "",
                Body                         = "",
                Subtitle                     = "",
                ShowInForeground             = true,
                ForegroundPresentationOption = (PresentationOption.Alert | PresentationOption.Sound),
                CategoryIdentifier           = "category_a",
                ThreadIdentifier             = "thread1",
                Trigger                      = timeTrigger,
            };

            iOSNotificationCenter.ScheduleNotification(notificationIOS);

            var dailyNotificationIOS = new iOSNotification()
            {
                // You can optionally specify a custom identifier which can later be
                // used to cancel the notification, if you don't set one, a unique
                // string will be generated automatically.
                Identifier                   = "one_day",
                Title                        = "",
                Body                         = "",
                Subtitle                     = "",
                ShowInForeground             = true,
                ForegroundPresentationOption = (PresentationOption.Alert | PresentationOption.Sound),
                CategoryIdentifier           = "category_a",
                ThreadIdentifier             = "thread1",
                Trigger                      = dailyTimeTrigger,
            };

            iOSNotificationCenter.ScheduleNotification(dailyNotificationIOS);
#endif
        }
        else //cancel notifications when app is foreground
        {
#if UNITY_ANDROID
            AndroidNotificationCenter.CancelAllNotifications();
#elif UNITY_IOS
            var allNotifications = iOSNotificationCenter.GetScheduledNotifications();
            foreach (var n in allNotifications)
            {
                iOSNotificationCenter.RemoveScheduledNotification(n.Identifier);
            }
#endif
        }
    }