private void AddMessageToDataSource(Twilio.IPMessaging.Message message) { var identity = JsonConvert.DeserializeObject <IdentityToken>(message.Author); // Get Agent Avatar if (identity.identityId != AppSettingsManager.ClientId && GravatarManager.GetImage(GravatarUser.Agent) == null) { GravatarManager.SetImage(GravatarUser.Agent, identity.picture); } // Get Customer Avatar if (identity.identityId == AppSettingsManager.ClientId && GravatarManager.GetImage(GravatarUser.Customer) == null) { GravatarManager.SetImage(GravatarUser.Customer, identity.picture); } var jmsg = new JMessage ( identity.identityId, identity.name, message.DateUpdatedAsDate, message.Body ); messages.Add(jmsg); SystemSoundPlayer.PlayMessageReceivedSound(); FinishReceivingMessage(true); ScrollToBottom(true); }
public override IMessageData GetMessageData(MessagesCollectionView collectionView, NSIndexPath indexPath) { MessageViewModel msg = viewModel.Messages [indexPath.Row]; TextMessageViewModel msgAsText = msg as TextMessageViewModel; ImageMessageViewModel msgAsImage = msg as ImageMessageViewModel; string senderId = msg.IsIncoming ? viewModel.Friend.FriendId.ToString() : SenderId; string senderName = msg.IsIncoming ? viewModel.Friend.Name : SenderDisplayName; if (string.IsNullOrWhiteSpace(senderName)) { senderName = string.Empty; } NSDate msgDate = (NSDate)(new DateTime(msg.Timestamp.Ticks, DateTimeKind.Utc)); var result = new JSQMessagesViewController.Message(senderId, senderName, msgDate, msgAsImage != null ? "Image message" : msgAsText.Text); return(result); }
public override IMessageData GetMessageData (MessagesCollectionView collectionView, NSIndexPath indexPath) { MessageViewModel msg = viewModel.Messages [indexPath.Row]; TextMessageViewModel msgAsText = msg as TextMessageViewModel; ImageMessageViewModel msgAsImage = msg as ImageMessageViewModel; string senderId = msg.IsIncoming ? viewModel.Friend.FriendId.ToString () : SenderId; string senderName = msg.IsIncoming ? viewModel.Friend.Name : SenderDisplayName; if (string.IsNullOrWhiteSpace (senderName)) senderName = string.Empty; NSDate msgDate = (NSDate)(new DateTime (msg.Timestamp.Ticks, DateTimeKind.Utc)); var result = new JSQMessagesViewController.Message (senderId, senderName, msgDate, msgAsImage != null ? "Image message" : msgAsText.Text); return result; }