コード例 #1
0
        public void scheduleLocalNotification(LocalNotificationData notificationData)
        {
            var notification = createNotification(notificationData);
            var externalId   = AndroidNotificationCenter.SendNotification(notification, channelId);

            notificationEquivalences.addEquivalence(notificationData.id, externalId);
            updateScheduledTime(notificationData);
        }
コード例 #2
0
 public void scheduleLocalNotification(LocalNotificationData notificationData)
 {
     if (mDebug)
     {
         string repeating = notificationData.isRepeatingNotification ? "(repeating)" : "";
         Debug.Log("schedule local notification: " + notificationData.id + " - " + notificationData.title + " " + repeating);
     }
 }
        private void schedule(LocalNotificationData notificationData)
        {
            var notification = getIOSLocalNotification(notificationData);

            UnityEngine.iOS.NotificationServices.ScheduleLocalNotification(notification);
            var dateTime = getIosUtcDateTime(notification);

            notificationData.utcScheduledTime = dateTime;
        }
コード例 #4
0
        private bool notificationHappenedJustBeforeOpen(LocalNotificationData n)
        {
            if (!n.hasNotificationDate)
            {
                return(false);
            }
            var secondsSinceScheduleTime = (float)(TimeExtensions.currentUtcTime - n.utcScheduledTime).TotalSeconds;

            return(secondsSinceScheduleTime < maxSecondsFromNotificationToOpen && secondsSinceScheduleTime >= 0.0f);
        }
コード例 #5
0
        private static AndroidNotification createNotification(LocalNotificationData notificationData)
        {
            var notification = new AndroidNotification();

            notification.Title    = notificationData.title;
            notification.Text     = notificationData.text;
            notification.FireTime = System.DateTime.Now.AddHours(notificationData.triggerInHours);
            if (notificationData.isRepeatingNotification)
            {
                notification.RepeatInterval = TimeSpan.FromHours(notificationData.intervalInHours);
            }
            return(notification);
        }
コード例 #6
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);
        }
コード例 #7
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);
        }
コード例 #8
0
 public void scheduleLocalNotification(LocalNotificationData notificationData)
 {
     if (isInitialized)
     {
         if (!notificationData.isRepeatingNotification)
         {
             Manager.Instance.ScheduleNotification(notificationData.triggerInHours.hoursToSeconds(),
                                                   notificationData.title, notificationData.text, notificationData.id,
                                                   notificationProfile: notificationData.profile, badgeNumber: notificationData.badge);
         }
         else
         {
             Manager.Instance.ScheduleNotificationRepeating(notificationData.triggerInHours.hoursToSeconds(),
                                                            notificationData.intervalInHours.hoursToSeconds(), notificationData.title, notificationData.text,
                                                            notificationData.id, notificationProfile: notificationData.profile, badgeNumber: notificationData.badge);
         }
         var timeSpan = TimeExtensions.hoursToTimeSpan(notificationData.triggerInHours);
         notificationData.utcScheduledTime = TimeExtensions.currentUtcTime.Add(timeSpan);
     }
 }
        public LocalNotification getIOSLocalNotification(LocalNotificationData notification)
        {
            LocalNotification newNotification = new LocalNotification();

            newNotification.alertAction = notification.title;
            newNotification.alertBody   = notification.text;
            newNotification.fireDate    = notification.triggerInHours.localDateTimeAfterThisHours();
            if (notification.isRepeatingNotification)
            {
                newNotification.repeatInterval = IosUtils.convertToCalendarUnit(notification.intervalInHours);
            }
            // TODO: should it accept actions?
            newNotification.hasAction = false;
            newNotification.applicationIconBadgeNumber = notification.badge;

            string notificationID = localIdToPhoneId(notification.id);
            Dictionary <string, string> userInfo = new Dictionary <string, string>(1);

            userInfo[ID_KEY]         = notificationID;
            userInfo[UTC_DATE_KEY]   = notification.triggerInHours.utcDateTimeAfterThisHours().utcToFileTimeString();
            newNotification.userInfo = userInfo;

            return(newNotification);
        }
 public void scheduleLocalNotification(LocalNotificationData notificationData)
 {
     schedule(notificationData);
 }
コード例 #11
0
        private static void updateScheduledTime(LocalNotificationData notificationData)
        {
            var timeSpan = TimeExtensions.hoursToTimeSpan(notificationData.triggerInHours);

            notificationData.utcScheduledTime = TimeExtensions.currentUtcTime.Add(timeSpan);
        }