public async void notify(string type, params object[] list) { switch (type) { case "new messages": //Add the messages to the list from the UI thread. Device.BeginInvokeOnMainThread(() => { if (vm.Messages != null && vm.Messages.Count > 0) { MessageListView.ScrollTo(vm.Messages.Last(), ScrollToPosition.End, false); } }); break; case "error": //Unexpected error AlertMessage("Unexpected Error", "Error while getting messages: " + list[0].ToString() + Environment.NewLine + "The chat will try to update automatically.", false); break; case "no internet": //No internet services AlertMessage("No internet", "The background of the page will become red and will stay red until there is no internet connectivity...", false); break; case "message error": //Too many failed attempts to send a message AlertMessage("Error sending message!", "Sending the message failed too many times... The message will not be sent." + Environment.NewLine + "Error: " + list[0].ToString(), false); break; case "session closed": //Cannot send messages to closed session, ask for chat copy AlertMessage("Session closed", "You cannot send anymore messages in this session because it was closed. If you want to ask another question open a new session. Do you want to get a copy of the chat on your email?", true); break; case "EmailError": //Error while sending email from SendGrid. AlertMessage("Error", "Error occured while sending chat copy:" + Environment.NewLine + list[0].ToString(), false); break; case "send copy": //User has confirmed to send a chat copy vm.SendChatCopy(); break; case "copy error": //Error while getting a chat copy from the server AlertMessage("FAIL", "Error while trying to get a session copy from the server." + Environment.NewLine + list[0].ToString(), false); break; case "email response": Response response = (Response)list[0]; //Check if the enquiry was sent successfully if (response.StatusCode == HttpStatusCode.Accepted) { AlertMessage("Sucess", "Chat copy sent successfuly! If you cannot see the e-mail, please check your SPAM box.", false); } else { //Alert the user if not. AlertMessage("Fail", "Chat copy did not send successfuly. Error code:" + response.StatusCode.ToString(), false); } break; case "session error": AlertMessage("Error", "Unable to start chat session. Check your internet connectivity.", false); break; case "error host": AlertMessage("Error", "Unable to reach host after few attempts. Check your network connectivity. The app will try to reach the host again!", false); break; } }