• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# UILocalNotification类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中UILocalNotification的典型用法代码示例。如果您正苦于以下问题:C# UILocalNotification类的具体用法?C# UILocalNotification怎么用?C# UILocalNotification使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



UILocalNotification类属于命名空间,在下文中一共展示了UILocalNotification类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: ViewDidLoad

        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...");
                };
        }
开发者ID:xamarin,项目名称:monotouch-samples,代码行数:27,代码来源:ViewController.cs


示例2: ViewDidLoad

		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);

			};
		}
开发者ID:CBrauer,项目名称:monotouch-samples,代码行数:32,代码来源:Home_iPhone.xib.cs


示例3: CreateToastNotification

        /// <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
        }
开发者ID:inthehand,项目名称:Charming,代码行数:32,代码来源:ToastNotificationCreator.cs


示例4: ViewDidLoad

		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);
			};
		}
开发者ID:ARMoir,项目名称:mobile-samples,代码行数:31,代码来源:MyViewController.cs


示例5: ActionNotificationTouchDown

		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);
			}
		}
开发者ID:CasperWollesen,项目名称:CW.Samples,代码行数:31,代码来源:CW_IOS_SingleViewApplicationViewController.cs


示例6: ShowNotification

		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;
			}

		}
开发者ID:praveenmohanmm,项目名称:PurposeColor_Bkp_Code,代码行数:28,代码来源:IOSLocalNotificationsImpl.cs


示例7: CancelLocalNotification

        /// <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);
                });
        }
开发者ID:shamik94,项目名称:sensus,代码行数:36,代码来源:iOSSensusServiceHelper.cs


示例8: CreateNotification

 static UILocalNotification CreateNotification()
 {
     UILocalNotification notification = new UILocalNotification() {
         AlertBody = "New iBeacon event"
     };
     return notification;
 }
开发者ID:ChallengeEarth,项目名称:beacon-prototype,代码行数:7,代码来源:InfoViewController.cs


示例9: ViewDidLoad

        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);
            };
        }
开发者ID:jimbobbennett,项目名称:iBeaconsMiniHack,代码行数:29,代码来源:NotificationViewController.cs


示例10: WillFinishLaunching

        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;
        }
开发者ID:rzaitov,项目名称:ios_location_service,代码行数:25,代码来源:AppDelegate.cs


示例11: ReceivedLocalNotification

 public override void ReceivedLocalNotification(UIApplication application, UILocalNotification notification)
 {
     // Check if the application is in foreground, we do nothing
     if(application.ApplicationState == UIApplicationState.Active)
     {
     }
 }
开发者ID:ChallengeEarth,项目名称:beacon-prototype,代码行数:7,代码来源:AppDelegate.cs


示例12: FinishedLaunching

        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);
                }
            };
        }
开发者ID:Rajneesh360Logica,项目名称:monotouch-samples,代码行数:26,代码来源:AppDelegate.cs


示例13: ViewDidLoad

        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);
        }
开发者ID:CBrauer,项目名称:monotouch-samples,代码行数:26,代码来源:NotificationViewController.cs


示例14: HandleAction

		// 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;
		}
开发者ID:CBrauer,项目名称:monotouch-samples,代码行数:9,代码来源:AppDelegate.cs


示例15: ReceivedLocalNotification

		/// <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;
		}
开发者ID:King-of-Spades,项目名称:InvokeUia-for-System-Dialogs,代码行数:11,代码来源:AppDelegate.cs


示例16: BeaconManagerExitedRegion

        void BeaconManagerExitedRegion(object sender, CLRegionEventArgs e)
        {
            var notification = new UILocalNotification();

            notification.AlertBody = "Goodbye";

            UIApplication.SharedApplication.PresentLocalNotificationNow(notification);
        }
开发者ID:jimbobbennett,项目名称:iBeaconDemo,代码行数:8,代码来源:AppDelegate.cs


示例17: RecordNotificationReceived

        public void RecordNotificationReceived(UILocalNotification message)
        {
            NSObject id;

            if (message != null && message.UserInfo.TryGetValue (new NSString(PlatformAccess.BuddyPushKey), out id)) {
                PlatformAccess.Current.OnNotificationReceived (id.ToString());
            }
        }
开发者ID:halukmy,项目名称:Buddy-DotNET-SDK,代码行数:8,代码来源:IosPlatformAccess.cs


示例18: BeaconManagerEnteredRegion

        void BeaconManagerEnteredRegion(object sender, CLRegionEventArgs e)
        {
            var notification = new UILocalNotification();

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

            UIApplication.SharedApplication.PresentLocalNotificationNow(notification);
        }
开发者ID:jimbobbennett,项目名称:iBeaconDemo,代码行数:8,代码来源:AppDelegate.cs


示例19: ReceivedLocalNotification

 private void ReceivedLocalNotification(UILocalNotification notification)
 {
     Mvx.Resolve<IMvxMessenger>().Publish(new NotificationReceivedMessage(this)
     {
         Body = notification.AlertBody,
         Local = true,
         AlertAction = notification.AlertAction
     });
 }
开发者ID:sammyroller,项目名称:Cheesebaron.MvxPlugins,代码行数:9,代码来源:NotificationsAppDelegate.cs


示例20: ReceivedLocalNotification

        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();
        }
开发者ID:rzaitov,项目名称:ios_location_service,代码行数:9,代码来源:AppDelegate.cs



注:本文中的UILocalNotification类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# UIManager类代码示例发布时间:2022-05-24
下一篇:
C# UILabel类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap