示例#1
0
 public override int ScheduleLocalNotification(string body, int delay)
 {
     if (UIDevice.CurrentDevice.CheckSystemVersion(10, 0))
     {
         UNUserNotificationCenter     center  = UNUserNotificationCenter.Current;
         UNMutableNotificationContent content = new UNMutableNotificationContent();
         content.Body  = body;
         content.Sound = UNNotificationSound.Default;
         UNTimeIntervalNotificationTrigger trigger = UNTimeIntervalNotificationTrigger.CreateTrigger(delay, false);
         UNNotificationRequest             request = UNNotificationRequest.FromIdentifier(StringIdentifierFromInt(LocalNotificationUid), content, trigger);
         center.AddNotificationRequest(request, (NSError error) =>
         {
             if (error != null)
             {
                 Console.WriteLine("Something went wrong:" + error);
             }
         });
     }
     else
     {
         UILocalNotification localNotification = new UILocalNotification();
         localNotification.FireDate  = NSDate.FromTimeIntervalSinceNow(delay);
         localNotification.AlertBody = body;
         localNotification.TimeZone  = NSTimeZone.DefaultTimeZone;
         localNotification.UserInfo  = NSDictionary.FromObjectAndKey(NSNumber.FromInt32(LocalNotificationUid), new NSString(PWMLocalNotificationUidKey));
         UIApplication.SharedApplication.ScheduleLocalNotification(localNotification);
     }
     return(LocalNotificationUid++);
 }
        public override string Send(Notification notification)
        {
            var msgId    = notification.Id.HasValue ? notification.Id.Value.ToString() : Guid.NewGuid().ToString();
            var userInfo = new NSMutableDictionary();

            userInfo.Add(new NSString("MessageID"), new NSString(msgId));

            var not = new UILocalNotification
            {
                FireDate    = notification.SendTime.ToNSDate(),
                AlertAction = notification.Title,
                AlertBody   = notification.Message,
                SoundName   = notification.Sound,
                UserInfo    = userInfo
            };

            if (notification.Interval != NotificationInterval.None)
            {
                not.RepeatInterval = notification.Interval == NotificationInterval.Weekly ? NSCalendarUnit.Week : NSCalendarUnit.Day;
            }

            if (notification.BadgeCount.HasValue)
            {
                not.ApplicationIconBadgeNumber = notification.BadgeCount.Value;
            }

            UIApplication.SharedApplication.ScheduleLocalNotification(not);
            return(msgId);
        }
        public static void ShowNotification(Models.Notification _Notification)
        {
            if (DateTime.ParseExact(_Notification.START_DATE, Constants.TIME_FORMAT, null) > DateTime.Now)
            {
                var             HUINotification = new UILocalNotification();
                NSDateFormatter HFormatter      = new NSDateFormatter();
                HFormatter.DateFormat       = Params.Constants.TIME_FORMAT;
                HUINotification.FireDate    = HFormatter.Parse(_Notification.START_DATE);
                HUINotification.AlertTitle  = _Notification.CAPTION;
                HUINotification.AlertBody   = _Notification.DESCRIPTION;
                HUINotification.AlertAction = "ViewAlert";

                NSMutableDictionary HCustomDictionary = new NSMutableDictionary();

                HCustomDictionary.SetValueForKey(new NSNumber(_Notification.EVENT_IDENT != -1), new NSString("BY_EVENT"));
                if (_Notification.EVENT_IDENT != -1)
                {
                    HCustomDictionary.SetValueForKey(new NSNumber(_Notification.EVENT_IDENT), new NSString("EVENT_IDENT"));
                }
                else
                {
                    if (_Notification.EVENT_DATE != "")
                    {
                        HCustomDictionary.SetValueForKey(new NSString(_Notification.EVENT_DATE), new NSString("START_DATE"));
                    }
                }
                HUINotification.UserInfo = HCustomDictionary;
                UIApplication.SharedApplication.ScheduleLocalNotification(HUINotification);
            }
        }
        private UILocalNotification BuildUiNotification(string notificationId, string title, string message, Dictionary <string, string> extraInfo)
        {
            if (!NSThread.IsMain)
            {
                UILocalNotification createdNotification = null;
                UIApplication.SharedApplication.InvokeOnMainThread(() => createdNotification = BuildUiNotification(notificationId, title, message, extraInfo));

                return(createdNotification);
            }

            // Create a valid UI Notification.
            var validUiNotification = new UILocalNotification
            {
                AlertTitle = title,
                AlertBody  = message
            };

            // The notifiaction ID exists in the user info.
            var userInfoDictionary = new Dictionary <string, string>(extraInfo)
            {
                { NotificationScheduler.NotificationIdKey, notificationId }
            };

            validUiNotification.UserInfo = NSDictionary.FromObjectsAndKeys(userInfoDictionary.Values.ToArray <object>(), userInfoDictionary.Keys.ToArray <object>());


            // All done.
            return(validUiNotification);
        }
        /// <summary>
        /// Creates a toast notification with the required values.
        /// </summary>
        /// <param name="content">Text content.</param>
        /// <param name="title">Toast title.</param>
        /// <returns></returns>
        public static ToastNotification CreateToastNotification(string content, string title)
        {
#if WINDOWS_UWP || WINDOWS_APP || WINDOWS_PHONE_APP || WINDOWS_PHONE_81
            XmlDocument doc = Windows.UI.Notifications.ToastNotificationManager.GetTemplateContent(ToastTemplateType.ToastText02);
            var textElements = doc.GetElementsByTagName("text");
            textElements[0].InnerText = title;
            textElements[1].InnerText = content;
            return new ToastNotification(new Windows.UI.Notifications.ToastNotification(doc));
#elif WINDOWS_PHONE
            return new ToastNotification(new Microsoft.Phone.Shell.ShellToast() { Title = title, Content = content });
#elif __ANDROID__
            Toast toast = Toast.MakeText(Plugin.CurrentActivity.CrossCurrentActivity.Current.Activity, title + "\r\n" + content, ToastLength.Long);
            return new ToastNotification(toast);
#elif __IOS__
            UILocalNotification localNotification = new UILocalNotification();
            localNotification.AlertTitle = title;
            localNotification.AlertBody = content;
            localNotification.SoundName = UILocalNotification.DefaultSoundName;
            //localNotification.RepeatCalendar = global::Foundation.NSCalendar.CurrentCalendar;
            //localNotification.RepeatInterval = global::Foundation.NSCalendarUnit.Minute;

            return new ToastNotification(localNotification);
#else
            return new ToastNotification(content, title);
#endif
        }
示例#6
0
        private void ScheduleCallbackAsync(string callbackId, int delayMS, bool repeating, int repeatDelayMS, string userNotificationMessage)
        {
            Device.BeginInvokeOnMainThread(() =>
            {
                UILocalNotification notification = new UILocalNotification
                {
                    FireDate  = DateTime.UtcNow.AddMilliseconds((double)delayMS).ToNSDate(),
                    AlertBody = userNotificationMessage,
                    UserInfo  = GetNotificationUserInfoDictionary(callbackId, repeating, repeatDelayMS)
                };

                // user info can be null if we don't have an activation ID...don't schedule the notification if this happens.
                if (notification.UserInfo == null)
                {
                    return;
                }

                if (userNotificationMessage != null)
                {
                    notification.SoundName = UILocalNotification.DefaultSoundName;
                }

                lock (_callbackIdNotification)
                    _callbackIdNotification.Add(callbackId, notification);

                UIApplication.SharedApplication.ScheduleLocalNotification(notification);

                Logger.Log("Callback " + callbackId + " scheduled for " + notification.FireDate + " (" + (repeating ? "repeating" : "one-time") + "). " + _callbackIdNotification.Count + " total callbacks in iOS service helper.", LoggingLevel.Debug, GetType());
            });
        }
		public void ShowNotification(string title, string messageTitle, string messege, bool handleClickNeeded )
		{
			try
			{
				string chatMsg = messege;
				string chatTouserID = "";
				if( title == "chat" )
				{
					string[] delimiters = { "&&" };
					string[] clasIDArray = messege.Split(delimiters, StringSplitOptions.None);
					chatMsg = clasIDArray [0];
					chatTouserID = clasIDArray [1];
				}
				AppDelegate.CurrentNotificationType = title;
				UILocalNotification notification = new UILocalNotification();
				notification.AlertTitle = messageTitle;
				notification.FireDate = NSDate.Now;
				notification.AlertAction = messageTitle;
				notification.AlertBody = chatMsg;
				notification.SoundName = UILocalNotification.DefaultSoundName;
				UIApplication.SharedApplication.ScheduleLocalNotification(notification);
			} 
			catch (Exception ex)
			{
				string err = ex.Message;
			}

		}
 static UILocalNotification CreateNotification()
 {
     UILocalNotification notification = new UILocalNotification() {
         AlertBody = "New iBeacon event"
     };
     return notification;
 }
示例#9
0
        /// <summary>
        /// Cancels a UILocalNotification. This will succeed in one of two conditions:  (1) if the notification to be
        /// cancelled is scheduled (i.e., not delivered); and (2) if the notification to be cancelled has been delivered
        /// and if the object passed in is the actual notification and not, for example, the one that was passed to
        /// ScheduleLocalNotification -- once passed to ScheduleLocalNotification, a copy is made and the objects won't test equal
        /// for cancellation.
        /// </summary>
        /// <param name="notification">Notification to cancel.</param>
        private static void CancelLocalNotification(UILocalNotification notification)
        {
            Device.BeginInvokeOnMainThread(() =>
            {
                string notificationId = notification.UserInfo.ValueForKey(new NSString(SENSUS_CALLBACK_ID_KEY)).ToString();

                // a local notification can be one of two types:  (1) scheduled, in which case it hasn't yet been delivered and should reside
                // within the shared application's list of scheduled notifications. the tricky part here is that these notification objects
                // aren't reference-equal, so we can't just pass `notification` to CancelLocalNotification. instead, we must search for the
                // notification by id and cancel the appropriate scheduled notification object.
                bool notificationCanceled = false;
                foreach (UILocalNotification scheduledNotification in UIApplication.SharedApplication.ScheduledLocalNotifications)
                {
                    string scheduledNotificationId = scheduledNotification.UserInfo.ValueForKey(new NSString(SENSUS_CALLBACK_ID_KEY)).ToString();
                    if (scheduledNotificationId == notificationId)
                    {
                        UIApplication.SharedApplication.CancelLocalNotification(scheduledNotification);
                        notificationCanceled = true;
                    }
                }

                // if we didn't cancel the notification above, then it isn't scheduled and should have already been delivered. if it has been
                // delivered, then our only option for cancelling it is to pass `notification` itself to CancelLocalNotification. this assumes
                // that `notification` is the actual notification object and not, for example, the one originally passed to ScheduleLocalNotification.
                if (!notificationCanceled)
                {
                    UIApplication.SharedApplication.CancelLocalNotification(notification);
                }
            });
        }
示例#10
0
        public override void FinishedLaunching(UIApplication application)
        {
            locationManager = new CLLocationManager();

            // A user can transition in or out of a region while the application is not running.
            // When this happens CoreLocation will launch the application momentarily, call this delegate method
            // and we will let the user know via a local notification.
            locationManager.DidDetermineState += (sender, e) => {
                string body = null;
                if (e.State == CLRegionState.Inside)
                {
                    body = "You're inside the region";
                }
                else if (e.State == CLRegionState.Outside)
                {
                    body = "You're outside the region";
                }

                if (body != null)
                {
                    var notification = new UILocalNotification()
                    {
                        AlertBody = body
                    };

                    // If the application is in the foreground, it will get called back to ReceivedLocalNotification
                    // If its not, iOS will display the notification to the user.
                    UIApplication.SharedApplication.PresentLocalNotificationNow(notification);
                }
            };
        }
		public override void ViewDidLoad ()
		{
			base.ViewDidLoad ();

			//---- when the add 1 minute notification is clicked, add a notification that fires
			// 1 minute from now
			btnAddLocalNotification.TouchUpInside += (s, e) => {
				//---- create the notification
				UILocalNotification notification = new UILocalNotification ();

				//---- set the fire date (the date time in which it will fire)
				var fireDate = DateTime.Now.AddSeconds (60);
				notification.FireDate = (NSDate)fireDate;

				//---- configure the alert stuff
				notification.AlertAction = "View Alert";
				notification.AlertBody = "Your one minute alert has fired!";

				//---- modify the badge
				notification.ApplicationIconBadgeNumber = 1;

				//---- set the sound to be the default sound
				notification.SoundName = UILocalNotification.DefaultSoundName;

//				notification.UserInfo = new NSDictionary();
//				notification.UserInfo[new NSString("Message")] = new NSString("Your 1 minute notification has fired!");

				//---- schedule it
				UIApplication.SharedApplication.ScheduleLocalNotification (notification);

			};
		}
        //Test button voor notificatie te sturen
        partial void BtnNotification30256_TouchUpInside(btnNotification sender)
        {
            // create the notification
            var notification = new UILocalNotification();

            // set the fire date (the date time in which it will fire)
            notification.FireDate = NSDate.FromTimeIntervalSinceNow(5);

            // configure the alert
            string body = GlobalVariables.weatherUpdate.Currently.Temp + " " + GlobalVariables.weatherUpdate.Currently.Summary;

            //notification.AlertLaunchImage = "iconv3.png";
            notification.AlertAction = "Today's prediction"; //Watch Alert
            notification.AlertTitle  = "Today's prediction"; //View Alert
            notification.AlertBody   = body;

            // modify the badge
            notification.ApplicationIconBadgeNumber = 1;

            // set the sound to be the default sound
            notification.SoundName = UILocalNotification.DefaultSoundName;

            // schedule it
            UIApplication.SharedApplication.ScheduleLocalNotification(notification);
        }
示例#13
0
        public object ScheduleLocalNotificationRepeat(DateTime dateTime, string message, RepeatEachTime repeat)
        {
            UILocalNotification localNotification = new UILocalNotification();

            localNotification.SoundName = UILocalNotification.DefaultSoundName.ToString();

            NSDate date = dateTime.DateTimeToNSDate();

            Debug.WriteLine("date :" + date.ToString());
            localNotification.FireDate  = date;
            localNotification.AlertBody = message;

            switch (repeat)
            {
            case RepeatEachTime.Week:
                localNotification.RepeatInterval = NSCalendarUnit.Week;
                break;

            default:
                break;
            }

            UIApplication.SharedApplication.ScheduleLocalNotification(localNotification);
            return(localNotification);
        }
示例#14
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            button.TouchUpInside += (sender, e) =>
            {
                // create the notification
                var notification = new UILocalNotification();

                // set the fire date (the date time in which it will fire)
                notification.FireDate = NSDate.FromTimeIntervalSinceNow(10);

                // configure the alert
                notification.AlertAction = "View Alert";
                notification.AlertBody   = "Your 10 second alert has fired!";

                // modify the badge
                notification.ApplicationIconBadgeNumber = 1;

                // set the sound to be the default sound
                notification.SoundName = UILocalNotification.DefaultSoundName;

                // schedule it
                UIApplication.SharedApplication.ScheduleLocalNotification(notification);
                Console.WriteLine("Scheduled...");
            };
        }
示例#15
0
        void ChangeExercise(UILocalNotification localNotification)
        {
            var exerciseName     = localNotification.UserInfo[Constants.ExerciseName].ToString();
            var exerciseQuantity = int.Parse(localNotification.UserInfo[Constants.ExerciseQuantity].ToString());

            _serviceManager.AddInstantExerciseNotificationAndRestartService(exerciseName, exerciseQuantity);
        }
示例#16
0
        /// <summary>
        /// Notifies the specified notification.
        /// </summary>
        /// <param name="notification">The notification.</param>
        public object Notify(LocalNotification notification)
        {
            var id = Guid.NewGuid().ToString();
            var nativeNotification = new UILocalNotification
            {
                AlertAction = notification.Title,
                AlertBody   = notification.Text,
                FireDate    = notification.NotifyTime.ToNSDate(),
                //ApplicationIconBadgeNumber = 1,
                //UserInfo = NSDictionary.FromObjectAndKey(NSObject.FromObject(id), NSObject.FromObject(NotificationKey))
            };

            if (!string.IsNullOrEmpty(notification.Parameter))
            {
                nativeNotification.UserInfo = NSDictionary.FromObjectsAndKeys(
                    new NSObject[] { NSObject.FromObject(notification.Parameter), NSObject.FromObject(id) },
                    new NSObject[] { NSObject.FromObject(ArgumentKey), NSObject.FromObject(NotificationKey) }
                    );
            }
            else
            {
                nativeNotification.UserInfo = NSDictionary.FromObjectAndKey(NSObject.FromObject(id), NSObject.FromObject(NotificationKey));
            }

            UIApplication.SharedApplication.ScheduleLocalNotification(nativeNotification);

            return(id);
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            Title         = "Notification Demo";
            beaconManager = new BeaconManager();
            beaconRegion  = new CLBeaconRegion(Beacon.ProximityUuid, ushort.Parse(Beacon.Major.ToString()), ushort.Parse(Beacon.Minor.ToString()), "BeaconSample");

            beaconRegion.NotifyOnEntry = enterSwitch.On;
            beaconRegion.NotifyOnExit  = exitSwitch.On;

            enterSwitch.ValueChanged += HandleValueChanged;
            exitSwitch.ValueChanged  += HandleValueChanged;

            beaconManager.StartMonitoring(beaconRegion);

            beaconManager.ExitedRegion += (sender, e) =>
            {
                var notification = new UILocalNotification();
                notification.AlertBody = "Exit region notification";
                UIApplication.SharedApplication.PresentLocalNotificationNow(notification);
            };

            beaconManager.EnteredRegion += (sender, e) =>
            {
                var notification = new UILocalNotification();
                notification.AlertBody = "Enter region notification";
                UIApplication.SharedApplication.PresentLocalNotificationNow(notification);
            };
        }
示例#18
0
        public override void ReceivedLocalNotification(UIApplication application, UILocalNotification notification)
        {
            UIAlertController okayAlertController = UIAlertController.Create(notification.AlertAction, notification.AlertBody, UIAlertControllerStyle.Alert);

            okayAlertController.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Default, null));
            UIApplication.SharedApplication.ApplicationIconBadgeNumber = 0;
        }
示例#19
0
        //iOS 10 below notification
        public override void ReceivedLocalNotification(UIApplication application, UILocalNotification notification)
        {
            // show an alert
            UIAlertController okayAlertController = UIAlertController.Create(notification.AlertAction, notification.AlertBody, UIAlertControllerStyle.ActionSheet);

            if (notification.AlertTitle.Equals("LocationCheck"))
            {
                okayAlertController.AddAction(UIAlertAction.Create("Yes. Share my experience!", UIAlertActionStyle.Default, alertAction => ShareRating()));
                okayAlertController.AddAction(UIAlertAction.Create("Yes. Remind me later to share", UIAlertActionStyle.Default, alertAction => ThirtyMinutes()));
                okayAlertController.AddAction(UIAlertAction.Create("Not this time", UIAlertActionStyle.Default, alertAction => NoAction()));
            }
            else if (notification.AlertTitle.Equals("Reminder2"))
            {
                okayAlertController.AddAction(UIAlertAction.Create("Yes", UIAlertActionStyle.Default, alertAction => ShareRating()));
                //okayAlertController.AddAction(UIAlertAction.Create("No", UIAlertActionStyle.Default, alertAction => YesAction()));
            }
            else if (notification.AlertTitle.Equals("ShareSchedule"))
            {
            }

            var window = UIApplication.SharedApplication.KeyWindow;

            window.RootViewController.PresentViewController(okayAlertController, true, null);

            // reset our badge
            UIApplication.SharedApplication.ApplicationIconBadgeNumber = 0;
        }
示例#20
0
        public void SetAlarm(AppModels.UserCondition condition)
        {
            long waitTime = condition.ReminderIntervalMillis();

            if (waitTime <= 0)
            {
                return;
            }

            CancelAlarm(condition);

            UIApplication.SharedApplication.CancelAllLocalNotifications();

            UILocalNotification notif = new UILocalNotification();

            notif.FireDate = NSDate.FromTimeIntervalSinceNow(waitTime / 1000);

            notif.RepeatCalendar              = NSCalendar.CurrentCalendar;
            notif.RepeatInterval              = GetCalUnit(waitTime);
            notif.AlertAction                 = string.Format("{0} Reminder", condition.Condition);
            notif.AlertBody                   = string.Format("Remember to take a photo of your condition '{0}'!", condition.Condition);
            notif.UserInfo                    = NSDictionary.FromObjectAndKey(new NSString(condition.Id.ToString()), new NSString(condition.Id.ToString()));
            notif.ApplicationIconBadgeNumber += 1;
            notif.SoundName                   = UILocalNotification.DefaultSoundName;

            UIApplication.SharedApplication.ScheduleLocalNotification(notif);
        }
示例#21
0
        //
        // This method is invoked when the application has loaded and is ready to run. In this
        // method you should instantiate the window, load the UI into it and then make the window
        // visible.
        //
        // You have 17 seconds to return from this method, or iOS will terminate your application.
        //
        public override bool FinishedLaunching(UIApplication app, NSDictionary options)
        {
            global::Xamarin.Forms.Forms.Init();
            LoadApplication(new App());

            if (UIDevice.CurrentDevice.CheckSystemVersion(8, 0))
            {
                var notificationSettings = UIUserNotificationSettings.GetSettingsForTypes(
                    UIUserNotificationType.Alert | UIUserNotificationType.Badge | UIUserNotificationType.Sound, null
                    );

                app.RegisterUserNotificationSettings(notificationSettings);
            }


            // check for a notification
            if (options != null)
            {
                if (options.ContainsKey(UIApplication.LaunchOptionsLocalNotificationKey))
                {
                    UILocalNotification localNotification = options[UIApplication.LaunchOptionsLocalNotificationKey] as UILocalNotification;
                    if (localNotification != null)
                    {
                        new UIAlertView(localNotification.AlertAction, localNotification.AlertBody, null, "OK", null).Show();
                        // reset our badge
                        UIApplication.SharedApplication.ApplicationIconBadgeNumber = 0;
                    }
                }
            }

            return(base.FinishedLaunching(app, options));
        }
示例#22
0
        /// <summary>
        /// Cancels a UILocalNotification. This will succeed in one of two conditions:  (1) if the notification to be
        /// cancelled is scheduled (i.e., not delivered); and (2) if the notification to be cancelled has been delivered
        /// and if the object passed in is the actual notification and not, for example, the one that was passed to
        /// ScheduleLocalNotification -- once passed to ScheduleLocalNotification, a copy is made and the objects won't test equal
        /// for cancellation.
        /// </summary>
        /// <param name="notification">Notification to cancel.</param>
        private static void CancelLocalNotification(UILocalNotification notification)
        {
            Device.BeginInvokeOnMainThread(() =>
                {
                    string notificationId = notification.UserInfo.ValueForKey(new NSString(SENSUS_CALLBACK_ID_KEY)).ToString();

                    // a local notification can be one of two types:  (1) scheduled, in which case it hasn't yet been delivered and should reside
                    // within the shared application's list of scheduled notifications. the tricky part here is that these notification objects
                    // aren't reference-equal, so we can't just pass `notification` to CancelLocalNotification. instead, we must search for the 
                    // notification by id and cancel the appropriate scheduled notification object.
                    bool notificationCanceled = false;
                    foreach (UILocalNotification scheduledNotification in UIApplication.SharedApplication.ScheduledLocalNotifications)
                    {
                        string scheduledNotificationId = scheduledNotification.UserInfo.ValueForKey(new NSString(SENSUS_CALLBACK_ID_KEY)).ToString();
                        if (scheduledNotificationId == notificationId)
                        {
                            UIApplication.SharedApplication.CancelLocalNotification(scheduledNotification);
                            notificationCanceled = true;
                        }
                    }

                    // if we didn't cancel the notification above, then it isn't scheduled and should have already been delivered. if it has been 
                    // delivered, then our only option for cancelling it is to pass `notification` itself to CancelLocalNotification. this assumes
                    // that `notification` is the actual notification object and not, for example, the one originally passed to ScheduleLocalNotification.
                    if (!notificationCanceled)
                        UIApplication.SharedApplication.CancelLocalNotification(notification);
                });
        }
        public void CreateNotification(string title, string message)
        {
            // create the notification
            var notification = new UILocalNotification();

            //// set the fire date (the date time in which it will fire)
            //notification.FireDate = NSDate.FromTimeIntervalSinceNow(secs);

            // configure the alert

            notification.AlertBody  = message;
            notification.AlertTitle = title;
            //notification.AlertAction = date;



            // modify the badge
            notification.ApplicationIconBadgeNumber = 1;

            // set the sound to be the default sound
            notification.SoundName = UILocalNotification.DefaultSoundName;


            // schedule it
            UIApplication.SharedApplication.ScheduleLocalNotification(notification);
        }
示例#24
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            button.TouchUpInside += (sender, e) =>
                {
                    // create the notification
                    var notification = new UILocalNotification();

                    // set the fire date (the date time in which it will fire)
                    notification.FireDate = NSDate.FromTimeIntervalSinceNow(10);

                    // configure the alert
                    notification.AlertAction = "View Alert";
                    notification.AlertBody = "Your 10 second alert has fired!";

                    // modify the badge
                    notification.ApplicationIconBadgeNumber = 1;

                    // set the sound to be the default sound
                    notification.SoundName = UILocalNotification.DefaultSoundName;

                    // schedule it
                    UIApplication.SharedApplication.ScheduleLocalNotification(notification);
                    Console.WriteLine("Scheduled...");
                };
        }
示例#25
0
        public override bool WillFinishLaunching(UIApplication application, NSDictionary launchOptions)
        {
            /*
            UILocalNotification tn = new UILocalNotification();
            tn.AlertBody = "WillFinishLaunching";
            UIApplication.SharedApplication.PresentLocationNotificationNow(tn);
            */

            if (launchOptions != null)
            {
                NSObject launchFromLocations;
                if(launchOptions.TryGetValue(UIApplication.LaunchOptionsLocationKey, out launchFromLocations))
                {
                    if(((NSNumber)launchFromLocations).BoolValue)
                    {
                        UILocalNotification ln = new UILocalNotification();
                        ln.AlertBody = "position changed!";
                        ln.AlertAction = "просмотреть";
                        UIApplication.SharedApplication.PresentLocationNotificationNow(ln);
                    }
                }
            }

            return true;
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad ();

            // Get the current state of the notification settings
            var settings = UIApplication.SharedApplication.CurrentUserNotificationSettings;

            // Wireup button
            SendButton.TouchUpInside += (sender, e) => {
                // Create a new local notification
                UILocalNotification notification = new UILocalNotification(){
                    AlertBody = "Go Bananas - You've got Monkey Mail!",
                    AlertAction = null,
                    ApplicationIconBadgeNumber = 1,
                    Category = "MONKEYMESSAGE_ID",
                    FireDate = NSDate.FromTimeIntervalSinceNow(15) // Fire message in 15 seconds
                };

                // Schedule the notification
                UIApplication.SharedApplication.ScheduleLocalNotification(notification);
                Console.WriteLine("Notification scheduled...");
            };

            // Enable the button if the application has been allowed to send notifications
            SendButton.Enabled = ((settings.Types & UIUserNotificationType.Alert) == UIUserNotificationType.Alert);
        }
示例#27
0
        /// <summary>
        /// Processes any received launch options.
        /// </summary>
        /// <param name="options">Options.</param>
        /// <param name="fromFinishedLaunching">True if this method comes from the 'FinishedLaunching' delegated method</param>
        /// <param name="applicationState">The application state that received the special launch options</param>
        public void processLaunchOptions(NSDictionary options, bool fromFinishedLaunching, UIApplicationState applicationState)
        {
            try {
                                #if DEBUG
                log("******* Checking launch optioins (if available) fromFinishedLaunching=" + fromFinishedLaunching + ". application state: " + applicationState);
                                #endif
                if (options != null)
                {
                    // LOCAL NOTIFICATIONS

                    UILocalNotification localNotif = (UILocalNotification)options.ObjectForKey(UIApplication.LaunchOptionsLocalNotificationKey);
                    this.ProcessLocalNotification(applicationState, localNotif);
                }
                else
                {
                                        #if DEBUG
                    log("******* NO launch options");
                                        #endif
                }
            } catch (System.Exception ex) {
                                #if DEBUG
                log("******* Unhandled exception when trying to process notification. fromFinishedLaunching[" + fromFinishedLaunching + "]. Exception message: " + ex.Message);
                                #endif
            }
        }
示例#28
0
        public void setNotif(string Title, string Desc, string date, string time, int interval)
        {
            try{
                //---- create the notification
                var notification = new UILocalNotification();

                //---- set the fire date (the date time in which it will fire)
                notification.FireDate = ConvertDateTimeToNSDate(date, time, interval);

                //---- configure the alert stuff
                notification.AlertTitle = Title;
                notification.AlertBody  = date + " " + time;

                //---- modify the badge
                notification.ApplicationIconBadgeNumber = 1;

                //---- set the sound to be the default sound
                notification.SoundName = UILocalNotification.DefaultSoundName;



                //---- schedule it
                UIApplication.SharedApplication.ScheduleLocalNotification(notification);
            }
            catch (Exception ex)
            {
                Services.Logs.Insights.Send("GetDateTimeMS", ex);
            }
        }
示例#29
0
        static void FireNotification(IList <Notification> news)
        {
            UILocalNotification notification = new UILocalNotification();

            notification.FireDate = NSDate.Now.AddSeconds(10);
            notification.ApplicationIconBadgeNumber = UIApplication.SharedApplication.ApplicationIconBadgeNumber + news.Count;

            if (news.Count > 1)
            {
                notification.AlertAction = "Notification Intranet";
                notification.AlertBody   = news.Count + " nouvelles notifications.";
            }
            else if (news.Count == 1)
            {
                notification.AlertAction = "Notification Intranet";
                notification.AlertBody   = API.HTMLCleaner.RemoveLinksKeepText(news [0].Title);
                NSMutableDictionary LinkDic = new NSMutableDictionary();
                int i = 0;
                foreach (var item in news[0].Links)
                {
                    LinkDic.SetValueForKey(NSObject.FromObject(item.Href), new NSString((i++).ToString()));
                }
                notification.UserInfo = LinkDic;
            }

            UIApplication.SharedApplication.ScheduleLocalNotification(notification);
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad ();
            Title = "Notification Demo";
            beaconManager = new BeaconManager ();
            beaconRegion = new BeaconRegion (Beacon.ProximityUUID, Beacon.Major, Beacon.Minor, "BeaconSample");

            beaconRegion.NotifyOnEntry = enterSwitch.On;
            beaconRegion.NotifyOnExit = exitSwitch.On;

            enterSwitch.ValueChanged += HandleValueChanged;
            exitSwitch.ValueChanged += HandleValueChanged;

            beaconManager.StartMonitoring (beaconRegion);

            beaconManager.ExitedRegion += (sender, e) =>
            {
                var notification = new UILocalNotification();
                notification.AlertBody = "Exit region notification";
                UIApplication.SharedApplication.PresentLocalNotificationNow(notification);
            };

            beaconManager.EnteredRegion += (sender, e) =>
            {
                var notification = new UILocalNotification();
                notification.AlertBody = "Enter region notification";
                UIApplication.SharedApplication.PresentLocalNotificationNow(notification);
            };
        }
示例#31
0
        private UILocalNotification PrepareLocalNotification(NotificationData notification)
        {
            if (notification != null)
            {
                UILocalNotification localNotification = new UILocalNotification();
                localNotification.AlertBody = notification.AlertMessage;
                localNotification.ApplicationIconBadgeNumber = notification.Badge;
                localNotification.SoundName = UILocalNotification.DefaultSoundName;                 // defaults
                if (notification.Sound != null && notification.Sound.Length > 0 && !notification.Sound.Equals("default"))
                {
                    // for sounds different from the default one
                    localNotification.SoundName = notification.Sound;
                }
                if (notification.CustomDataJsonString != null && notification.CustomDataJsonString.Length > 0)
                {
                    SystemLogger.Log(SystemLogger.Module.PLATFORM, "Custom Json String received: " + notification.CustomDataJsonString);

                    Dictionary <String, Object> userDictionary = (Dictionary <String, Object>)IPhoneUtils.GetInstance().JSONDeserialize <Dictionary <String, Object> >(notification.CustomDataJsonString);
                    localNotification.UserInfo = IPhoneUtils.GetInstance().ConvertToNSDictionary(userDictionary);
                }
                return(localNotification);
            }
            else
            {
                return(null);
            }
        }
        public override void FinishedLaunching(UIApplication application)
        {
            locationManager = new CLLocationManager ();

            if (UIDevice.CurrentDevice.CheckSystemVersion (8, 0)) {
                locationManager.RequestWhenInUseAuthorization ();
            }
            // A user can transition in or out of a region while the application is not running.
            // When this happens CoreLocation will launch the application momentarily, call this delegate method
            // and we will let the user know via a local notification.
            locationManager.DidDetermineState += (sender, e) => {
                string body = null;
                if (e.State == CLRegionState.Inside)
                    body = "You're inside the region";
                else if (e.State == CLRegionState.Outside)
                    body = "You're outside the region";

                if (body != null) {
                    var notification = new UILocalNotification () { AlertBody = body };

                    // If the application is in the foreground, it will get called back to ReceivedLocalNotification
                    // If its not, iOS will display the notification to the user.
                    UIApplication.SharedApplication.PresentLocalNotificationNow (notification);
                }
            };
        }
示例#33
0
        /// <summary>
        /// Processes the local notification.
        /// </summary>
        /// <param name="application">Application.</param>
        /// <param name="localNotification">Local notification.</param>
        private void ProcessLocalNotification(UIApplicationState applicationState, UILocalNotification localNotification)
        {
            if (localNotification != null)
            {
#if DEBUG
                log("******* Local NOTIFICATION received");
#endif

                if (applicationState == UIApplicationState.Active)
                {
                    // we need to manually process the notification while application is running.
#if DEBUG
                    log("******* Application is running, manually showing notification");
#endif
                    this.UpdateApplicationIconBadgeNumber((int)localNotification.ApplicationIconBadgeNumber);
                    this.PlayNotificationSound(localNotification.SoundName);
                    this.ShowNotificationAlert("Notification", localNotification.AlertBody);
                }

                NotificationData notificationData = new NotificationData();
                notificationData.AlertMessage = localNotification.AlertBody;
                notificationData.Badge        = (int)localNotification.ApplicationIconBadgeNumber;
                notificationData.Sound        = localNotification.SoundName;

                if (localNotification.UserInfo != null)
                {
                    Dictionary <String, Object> customDic = IPhoneUtils.GetInstance().ConvertToDictionary(new NSMutableDictionary(localNotification.UserInfo));
                    notificationData.CustomDataJsonString = IPhoneUtils.GetInstance().JSONSerialize(customDic);
                }

                IPhoneUtils.GetInstance().FireUnityJavascriptEvent("Appverse.OnLocalNotificationReceived", notificationData);
            }
        }
示例#34
0
        public void SendLocalNotification(string title, string description, int iconID, List <string> entrys, string name)
        {
            //---- when the add 1 minute notification is clicked, add a notification that fires
            // 1 second from now

            //---- create the notification
            UILocalNotification notification = new UILocalNotification();

            //---- set the fire date (the date time in which it will fire)
            var fireDate = DateTime.Now.AddSeconds(1);

            notification.FireDate = (NSDate)fireDate;

            //---- configure the alert stuff
            notification.AlertAction = description;
            notification.AlertBody   = entrys.ToString();

            //---- modify the badge
            notification.ApplicationIconBadgeNumber = 1;

            //---- set the sound to be the default sound
            notification.SoundName = UILocalNotification.DefaultSoundName;

            //				notification.UserInfo = new NSDictionary();
            //				notification.UserInfo[new NSString("Message")] = new NSString("Your 1 minute notification has fired!");

            //---- schedule it
            UIApplication.SharedApplication.ScheduleLocalNotification(notification);
        }
示例#35
0
        public override void ReceivedLocalNotification(UIApplication application, UILocalNotification notification)
        {
            // show an alert
            UIAlertController okayAlertController = UIAlertController.Create(notification.AlertTitle, notification.AlertBody, UIAlertControllerStyle.Alert);

            okayAlertController.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Default, null));

            Window.RootViewController.PresentViewController(okayAlertController, true, null);

            // reset our badge
            UIApplication.SharedApplication.ApplicationIconBadgeNumber = 0;

            Message newMsg = new Message(notification.AlertTitle, notification.AlertBody);



            // TODO
            // 1 create the object from the notification -> ok
            // 2 add this msg to messageTable
            // 3 refresh ViewController table


            string[] tableItems = new string[] { newMsg.Title, newMsg.Body };


            //mainController.UpdateAndRefreshMessages(newMsg);

            //table.Source = new TableSource(tableItems);
            //Add(table);
        }
示例#36
0
        public UILocalNotification[] GenerateFiveNotifications()
        {
            var notificationList = new List <UILocalNotification>();

            int triggerTime = 1;

            for (int i = 0; i < 5; i++)
            {
                var notification = new UILocalNotification();

                // configure the alert
                notification.AlertAction = "Alert Action: " + RandomString(6);
                notification.AlertTitle  = "Alert Title: " + RandomString(6);
                notification.AlertBody   = "This is the alert body: " + RandomString(20);

                // modify the badge
                notification.ApplicationIconBadgeNumber = 1;

                // set the sound to be the default sound
                notification.SoundName = UILocalNotification.DefaultSoundName;

                //notification = new UILocalNotification();

                // set the fire date (the date time in which it will fire)
                notification.FireDate = NSDate.FromTimeIntervalSinceNow(4 + triggerTime);

                triggerTime += 1;

                notificationList.Add(notification);
            }

            return(notificationList.ToArray());
        }
		void ActionNotificationTouchDown (object sender, EventArgs e)
		{
			int seconds;
			if(int.TryParse(_notificationTextField.Text, out seconds))
			{
				// create the notification
				var notification = new UILocalNotification();

				// set the fire date (the date time in which it will fire)
				notification.FireDate = DateTime.Now.AddSeconds(seconds);

				// configure the alert stuff
				notification.AlertAction = "Time for question";
				notification.AlertBody = _notificationMesssageTextField.Text + "(" + ++_notificationCount + ")";

				// modify the badge
				notification.ApplicationIconBadgeNumber = 1;

				// set the sound to be the default sound
				notification.SoundName = UILocalNotification.DefaultSoundName;

				// schedule it
				UIApplication.SharedApplication.ScheduleLocalNotification(notification);

				_notificationButton.SetTitle("Success (" + _notificationCount + ")", UIControlState.Normal);
			}
			else
			{
				_notificationButton.SetTitle ("Failed", UIControlState.Normal);
			}
		}
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            // Get the current state of the notification settings
            var settings = UIApplication.SharedApplication.CurrentUserNotificationSettings;

            // Wireup button
            SendButton.TouchUpInside += (sender, e) => {
                // Create a new local notification
                UILocalNotification notification = new UILocalNotification()
                {
                    AlertBody   = "Go Bananas - You've got Monkey Mail!",
                    AlertAction = null,
                    ApplicationIconBadgeNumber = 1,
                    Category = "MONKEYMESSAGE_ID",
                    FireDate = NSDate.FromTimeIntervalSinceNow(15)                     // Fire message in 15 seconds
                };

                // Schedule the notification
                UIApplication.SharedApplication.ScheduleLocalNotification(notification);
                Console.WriteLine("Notification scheduled...");
            };

            // Enable the button if the application has been allowed to send notifications
            SendButton.Enabled = ((settings.Types & UIUserNotificationType.Alert) == UIUserNotificationType.Alert);
        }
示例#39
0
        public bool LaunchNotification(UILocalNotification notification, bool isMainLauncher)
        {
            bool     didLaunch = false;
            NSString key       = new NSString("rescue_id");

            if (notification != null && notification.UserInfo != null && notification.UserInfo.ContainsKey(key)) //TODO:Should: Remove inline constant
            {
                string rescueID = notification.UserInfo[key].ToString();
                Rescue rescue   = Container.EscapeApp.RescueGetById(new Guid(rescueID));
                if (rescue != null)
                {
                    NotificationController notificationController = this.MainStoryboard.InstantiateViewController(NotificationController.IDENTIFIER) as NotificationController;
                    notificationController.Rescue = rescue;

                    // start with a new nav
                    UINavigationController navController = new UINavigationController(notificationController);
                    navController.NavigationBarHidden = true;
                    this.ChangeRootViewController(navController, UIViewAnimationOptions.TransitionNone);
                    didLaunch = true;
                }
            }


            if (!didLaunch && isMainLauncher)
            {
                this.LaunchMain();
            }

            return(didLaunch);
        }
示例#40
0
        public override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions)
        {
            // <Fake ioc>
            ICacheFileStore fileStore    = new IOSFileStore();
            ICacheHost      cacheHost    = new CacheHost(CoreAssumptions.INTERNAL_APP_NAME);
            IViewPlatform   viewPlatform = new IOSViewPlatform();
            IEscapeApp      escapeApp    = new EscapeApp(cacheHost, viewPlatform);

            Container.RegisterDependencies(fileStore, cacheHost, escapeApp, viewPlatform);
            // </Fake ioc>

            Container.EscapeApp.Initialize();

            this.InitializeEnvironment();

            this.MainStoryboard = UIStoryboard.FromName("MainStoryboard", null);
            this.Window         = new UIWindow(UIScreen.MainScreen.Bounds);

            if (launchOptions != null && launchOptions.ContainsKey(UIApplication.LaunchOptionsLocalNotificationKey))
            {
                UILocalNotification localNotification = launchOptions[UIApplication.LaunchOptionsLocalNotificationKey] as UILocalNotification;
                this.LaunchNotification(localNotification, true);
            }
            else
            {
                this.LaunchMain();
            }


            this.Window.MakeKeyAndVisible();

            return(true);
        }
示例#41
0
        //
        // This method is invoked when the application has loaded and is ready to run. In this
        // method you should instantiate the window, load the UI into it and then make the window
        // visible.
        //
        // You have 17 seconds to return from this method, or iOS will terminate your application.
        //
        public override bool FinishedLaunching(UIApplication app, NSDictionary options)
        {
            global::Xamarin.Forms.Forms.Init();
            LoadApplication(new App());

            DependencyService.Register <IosDeviceRegistration>();

            var notificationSettings = UIUserNotificationSettings.GetSettingsForTypes(
                UIUserNotificationType.Alert | UIUserNotificationType.Badge | UIUserNotificationType.Sound, null);

            app.RegisterUserNotificationSettings(notificationSettings);
            app.RegisterForRemoteNotifications();



            UILocalNotification notification = new UILocalNotification();

            notification.FireDate = NSDate.FromTimeIntervalSinceNow(3600);
            //notification.AlertTitle = "Alert Title"; // required for Apple Watch notifications
            notification.AlertAction = "View Alert";
            notification.AlertBody   = "Сашка, я тебя люблю!";
            UIApplication.SharedApplication.ScheduleLocalNotification(notification);



            return(base.FinishedLaunching(app, options));
        }
示例#42
0
		public override void ViewDidLoad ()
		{
			base.ViewDidLoad ();

			View.Frame = UIScreen.MainScreen.Bounds;
			View.BackgroundColor = UIColor.White;
			View.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight;
			AddButtonToView ();

			_button.TouchUpInside += (sender, e) =>
			{
				//---- create the notification
				var notification = new UILocalNotification ();

				//---- set the fire date (the date time in which it will fire)
				notification.FireDate = (NSDate)DateTime.Now.AddSeconds (15);

				//---- configure the alert stuff
				notification.AlertAction = "View Alert";
				notification.AlertBody = "Your one minute alert has fired!";

				//---- modify the badge
				notification.ApplicationIconBadgeNumber = 1;

				//---- set the sound to be the default sound
				notification.SoundName = UILocalNotification.DefaultSoundName;

				//---- schedule it
				UIApplication.SharedApplication.ScheduleLocalNotification (notification);
			};
		}
 public override void ReceivedLocalNotification(UIApplication application, UILocalNotification notification)
 {
     // Check if the application is in foreground, we do nothing
     if(application.ApplicationState == UIApplicationState.Active)
     {
     }
 }
示例#44
0
        void BeaconManagerEnteredRegion(object sender, CLRegionEventArgs e)
        {
            var notification = new UILocalNotification();

            notification.AlertBody = "Welcome to this beacons talk";

            UIApplication.SharedApplication.PresentLocalNotificationNow(notification);
        }
		/// <summary>
		///
		/// </summary>
		public override void ReceivedLocalNotification (UIApplication application, UILocalNotification notification)
		{
			// show an alert
			new UIAlertView(notification.AlertAction, notification.AlertBody, null, "OK", null).Show();

			// reset our badge
			UIApplication.SharedApplication.ApplicationIconBadgeNumber = 0;
		}
        public void RecordNotificationReceived(UILocalNotification message)
        {
            NSObject id;

            if (message != null && message.UserInfo.TryGetValue (new NSString(PlatformAccess.BuddyPushKey), out id)) {
                PlatformAccess.Current.OnNotificationReceived (id.ToString());
            }
        }
示例#47
0
        void BeaconManagerExitedRegion(object sender, CLRegionEventArgs e)
        {
            var notification = new UILocalNotification();

            notification.AlertBody = "Goodbye";

            UIApplication.SharedApplication.PresentLocalNotificationNow(notification);
        }
示例#48
0
		// iOS 8
		public override void HandleAction (UIApplication application, string actionIdentifier, UILocalNotification localNotification, Action completionHandler)
		{
			// show an alert
			new UIAlertView(localNotification.AlertAction, "?" + localNotification.AlertBody, null, "OK", null).Show();

			// reset our badge
			UIApplication.SharedApplication.ApplicationIconBadgeNumber = 0;
		}
示例#49
0
        public override void ReceivedLocalNotification(UIApplication application, UILocalNotification notification)
        {
            _lastLocalNotification = notification;
            _notificationAlert.Message = string.Format(
            @"Do you want to cancel it?
            Alertbody: {0}", notification.AlertBody);

            _notificationAlert.Show();
        }
 private void ReceivedLocalNotification(UILocalNotification notification)
 {
     Mvx.Resolve<IMvxMessenger>().Publish(new NotificationReceivedMessage(this)
     {
         Body = notification.AlertBody,
         Local = true,
         AlertAction = notification.AlertAction
     });
 }
示例#51
0
		public void Show (string message)
		{
			Device.BeginInvokeOnMainThread (() => {
				var notification = new UILocalNotification {
					FireDate = NSDate.FromTimeIntervalSinceNow (0),
					AlertBody = message
				};
				UIApplication.SharedApplication.ScheduleLocalNotification (notification);
			});
		}
示例#52
0
        public override void ReceivedLocalNotification(UIApplication application, UILocalNotification notification)
        {
            // show an alert
			UIAlertController okayAlertController = UIAlertController.Create (notification.AlertAction, notification.AlertBody, UIAlertControllerStyle.Alert);
			okayAlertController.AddAction (UIAlertAction.Create ("OK", UIAlertActionStyle.Default, null));
			viewController.PresentViewController (okayAlertController, true, null);

            // reset our badge
            UIApplication.SharedApplication.ApplicationIconBadgeNumber = 0;
        }
        private void TriggerManagerOnChangedState(object sender, TriggerChangedStateEventArgs args)
        {
            var notification = new UILocalNotification
            {
                AlertAction = "Your beer is at the wrong temperature!",
                SoundName = UILocalNotification.DefaultSoundName
            };

            UIApplication.SharedApplication.PresentLocalNotificationNow(notification);
        }
        /// <summary>
        /// Show a local notification in the Notification Center.
        /// </summary>
        /// <param name="title">Title of the notification</param>
        /// <param name="body">Body or description of the notification</param>
        public void Show(string title, string body)
        {
            var notification = new UILocalNotification
            {
                FireDate = (NSDate)DateTime.Now,
                AlertAction = title,
                AlertBody = body
            };

            UIApplication.SharedApplication.ScheduleLocalNotification(notification);
        }
        void HandleTriggerChangedState(object sender, TriggerChangedStateEventArgs e)
        {
            if(e.Trigger.Identifier == TriggerId && e.Trigger.State)
            {
                Console.WriteLine("You forgot your bag!");
                var notification = new UILocalNotification();
                notification.AlertBody = "You forgot your bag!";
                UIApplication.SharedApplication.PresentLocalNotificationNow(notification);

            }
        }
示例#56
0
        public override void ReceivedLocalNotification(UIApplication application, UILocalNotification notification)
        {
            Debug.WriteLine("Location Notification: {0}:{1}", notification.AlertAction, notification.AlertBody);
            //Debug.WriteLine("Location Notification: " + notification.AlertBody);

            if (UIApplication.SharedApplication.ApplicationState == UIApplicationState.Active) {
                new UIAlertView(notification.AlertAction, notification.AlertBody, null, "OK", null).Show();

                //var alert = UIAlertController.Create(notification.AlertAction, notification.AlertBody, UIAlertControllerStyle.Alert);
                //UIApplication.SharedApplication.KeyWindow.RootViewController.PresentViewController(alert, true, null);
            }
        }
		public override void ViewDidLoad ()
		{
			base.ViewDidLoad ();

			Near = UIImage.FromBundle ("Images/square_near");
			Far = UIImage.FromBundle ("Images/square_far");
			Immediate = UIImage.FromBundle ("Images/square_immediate");
			Unknown = UIImage.FromBundle ("Images/square_unknown");

			beaconUUID = new NSUuid (uuid);
			beaconRegion = new CLBeaconRegion (beaconUUID, beaconMajor, beaconId);


			beaconRegion.NotifyEntryStateOnDisplay = true;
			beaconRegion.NotifyOnEntry = true;
			beaconRegion.NotifyOnExit = true;

			locationmanager = new CLLocationManager ();

			locationmanager.RegionEntered += (object sender, CLRegionEventArgs e) => {
				if (e.Region.Identifier == beaconId) {

					var notification = new UILocalNotification () { AlertBody = "The Xamarin beacon is close by!" };
					UIApplication.SharedApplication.CancelAllLocalNotifications();
					UIApplication.SharedApplication.PresentLocationNotificationNow (notification);
				}
			};


			locationmanager.DidRangeBeacons += (object sender, CLRegionBeaconsRangedEventArgs e) => {
				if (e.Beacons.Length > 0) {

					CLBeacon beacon = e.Beacons [0];
					//this.Title = beacon.Proximity.ToString() + " " +beacon.Major + "." + beacon.Minor;
				}
					
				dataSource.Beacons = e.Beacons;
				TableView.ReloadData();
			};







			locationmanager.StartMonitoring (beaconRegion);
			locationmanager.StartRangingBeacons (beaconRegion);



			TableView.Source = dataSource = new DataSource (this);
		}
 public void Notify(string title, string message)
 {
     var notification = new UILocalNotification
     {
         FireDate = DateTime.Now,
         AlertAction = title,
         AlertBody = message,
         HasAction = true,
         SoundName = UILocalNotification.DefaultSoundName
     };
     UIApplication.SharedApplication.ScheduleLocalNotification(notification);
 }
        /// <summary>
        /// Schedule a local notification in the Notification Center.
        /// </summary>
        /// <param name="title">Title of the notification</param>
        /// <param name="body">Body or description of the notification</param>
        /// <param name="id">Id of the notification</param>
        /// <param name="notifyTime">The time you would like to schedule the notification for</param>
        public void Show(string title, string body, int id, DateTime notifyTime)
        {
            var notification = new UILocalNotification
            {
                FireDate = (NSDate)notifyTime,
                AlertAction = title,
                AlertBody = body,
                UserInfo = NSDictionary.FromObjectAndKey(NSObject.FromObject(id), NSObject.FromObject(NotificationKey))
            };

            UIApplication.SharedApplication.ScheduleLocalNotification(notification);
        }
      private UILocalNotification createNativeNotification(LocalNotification notification)
      {
          var nativeNotification = new UILocalNotification
          {
              AlertAction = notification.Title,
              AlertBody = notification.Text,
              FireDate = notification.NotifyTime,
              UserInfo = NSDictionary.FromObjectAndKey(NSObject.FromObject(notification.Id), NSObject.FromObject(NotificationKey))
          };

          return nativeNotification;
      }