//Create a new message and send it private void _SendButtonClicked() { //Check to see if there is an active conversation between the pre-defined participants if (activeConversation == null) { activeConversation = _GetConversation(); //If there isn't, create a new conversation with those participants if (activeConversation == null) { activeConversation = layerClient.NewConversation(MainActivity.GetAllParticipants()); } } _SendMessage(userInput.Text); //Clears the text input field userInput.Text = ""; }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); // Set our view from the "main" layout resource SetContentView(Resource.Layout.Main); // Get our button from the layout resource, // and attach an event to it Button button = FindViewById <Button>(Resource.Id.MyButton); button.Click += delegate { LayerClient layerClient = MyApp.Instance.LayerClient; // Creates and returns a new conversation object with sample participant identifiers Conversation conversation; if (layerClient.Conversations.Count == 0) { conversation = layerClient.NewConversation("948374839"); } else { conversation = layerClient.Conversations[0]; } // Create a message part with a string of text MessagePart messagePart = layerClient.NewMessagePart("text/plain", Encoding.UTF8.GetBytes("Hi, how are you?")); // Creates and returns a new message object with the given conversation and array of message parts IMessage message = layerClient.NewMessage(messagePart); // Sends the specified message to the conversation conversation.Send(message); }; }