public async override void ViewDidLoad() { base.ViewDidLoad(); // Perform any additional setup after loading the view, typically from a nib. dataSource = new MessagesDataSource(); tableView.Source = dataSource; tableView.RowHeight = UITableView.AutomaticDimension; tableView.EstimatedRowHeight = 70; var token = await GetToken(); this.NavigationItem.Prompt = $"Logged in as {identity}"; var accessManager = TwilioAccessManager.Create(token, this); client = TwilioIPMessagingClient.Create(accessManager, this); client.GetChannelsList((result, channels) => { generalChannel = channels.GetChannelWithUniqueName("general"); if (generalChannel != null) { generalChannel.Join(r => { Console.WriteLine("successfully joined general channel!"); }); } else { var options = new NSDictionary("TWMChannelOptionFriendlyName", "General Chat Channel", "TWMChannelOptionType", 0); channels.CreateChannel(options, (creationResult, channel) => { if (creationResult.IsSuccessful()) { generalChannel = channel; generalChannel.Join(r => { generalChannel.SetUniqueName("general", res => { }); }); } }); } }); NSNotificationCenter.DefaultCenter.AddObserver(UIKeyboard.WillShowNotification, KeyboardWillShow); NSNotificationCenter.DefaultCenter.AddObserver(UIKeyboard.DidShowNotification, KeyboardDidShow); NSNotificationCenter.DefaultCenter.AddObserver(UIKeyboard.WillHideNotification, KeyboardWillHide); this.View.AddGestureRecognizer(new UITapGestureRecognizer(() => { this.messageTextField.ResignFirstResponder(); })); this.messageTextField.Delegate = this; }
public async Task <bool> InitializeAsync() { var task = new TaskCompletionSource <bool>(); try { var token = await TwilioHelper.GetTokenAsync(); var accessManager = TwilioAccessManager.Create(token, this); client = TwilioIPMessagingClient.Create(accessManager, this); client.GetChannelsList((result, channels) => { generalChannel = channels.GetChannelWithUniqueName("general"); if (generalChannel != null) { generalChannel.Join(r => { Console.WriteLine("successfully joined general channel!"); task.SetResult(true); }); } else { var options = new NSDictionary("TWMChannelOptionFriendlyName", "General Chat Channel", "TWMChannelOptionType", 0); channels.CreateChannel(options, (creationResult, channel) => { if (creationResult.IsSuccessful()) { generalChannel = channel; generalChannel.Join(r => { generalChannel.SetUniqueName("general", res => { }); task.SetResult(true); }); } else { task.SetResult(false); } }); } }); } catch { return(false); } return(await task.Task.ConfigureAwait(false)); }
private async Task <TwilioIPMessagingClient> GetTwilioIpMessagingClient() { accessManagerDelegate = new AccessManagerDelegate(); ipMessagingDelegate = new IPMessagingDelegate(); ipMessagingDelegate.OnMessageAdded += AddMessageToDataSource; ipMessagingDelegate.OnClientReady += TwilioClientReady; var token = await viewModel.GetToken(AppSettingsManager.LoggedInUserEmail, AppSettingsManager.ClientId, AppSettingsManager.UserNickName, AppSettingsManager.UserPictureUrl); var accessManager = TwilioAccessManager.AccessManagerWithToken(token, accessManagerDelegate); client = TwilioIPMessagingClient.IpMessagingClientWithAccessManager(accessManager, new TwilioIPMessagingClientProperties(), ipMessagingDelegate); return(client); }
public override void AccessManagerTokenExpired(TwilioAccessManager accessManager) { Console.WriteLine("AccessManagerDelegate.AcessManagerTokenExpired()"); }
public override void AccessManager(TwilioAccessManager accessManager, NSError error) { Console.WriteLine("AccessManagerDelegate.AccessManager()"); }