//ADD THIS METHOD : public void NewMessageHandler(NSNotification obj) { int count = ALChatManager.GetUreadCount(); Console.WriteLine("Unread count is {0}", count); this.UreadCount.Text = "Unread count : " + count; }
public override void ViewWillAppear(bool animated) { base.ViewWillAppear(animated); NSNotificationCenter notification = NSNotificationCenter.DefaultCenter; //notification.AddObserver(this, new Selector("newMessageHandler"), // (NSString) "newMessageNotification",null); this.UreadCount.Text = "Unread count : " + ALChatManager.GetUreadCount(); notification.AddObserver((NSString)"newMessageNotification", NewMessageHandler); }
public override void ViewWillAppear(bool animated) { base.ViewWillAppear(animated); NSNotificationCenter notification = NSNotificationCenter.DefaultCenter; //notification.AddObserver(this, new Selector("newMessageHandler"), // (NSString) "newMessageNotification",null); this.UreadCount.Text = "Unread count : " + ALChatManager.GetUreadCount(); notification.AddObserver((NSString)"newMessageNotification", NewMessageHandler); if (this.NavigationController != null) { this.NavigationItem.SetLeftBarButtonItem( new UIBarButtonItem(UIBarButtonSystemItem.Cancel, (sender, args) => { this.DismissViewController(true, () => { }); }) , false); } }