/// <summary> /// If the user is Using a Android Device a Notification is Pushed /// </summary> /// <param name="updatedChat"></param> private void SendNotification(Chat updatedChat) { //Notification Specific code only exec when Android or IOS if (Device.RuntimePlatform == Device.Android || Device.RuntimePlatform == Device.iOS) { foreach (var msg in updatedChat.ChatMessages) { IReadOnlyList <Page> pages = App.Current.MainPage.Navigation.NavigationStack; //if the User is in a Conversation wher he is receiving new Msg no Notifications are Send for this chat if (pages[pages.Count - 1] is ChatPage) { ChatPage cp = pages[pages.Count - 1] as ChatPage; if (cp.Chat.Partner != msg.From) { notificationIDs.Add(notificationManager.ScheduleNotification(updatedChat.Partner, msg.Text)); } } else { notificationIDs.Add(notificationManager.ScheduleNotification(updatedChat.Partner, msg.Text)); } } } }
/// <summary> /// Adds a ChatSelection tile the the Chat seletion stack /// </summary> /// <param name="source"></param> /// <param name="args"></param> private void Chat_Added(object source, ChatEventArgs args) { ChatPage chatPage = new ChatPage(args.Chat); ChatSelectionTile chatSelectionTile = new ChatSelectionTile(chatPage); Device.BeginInvokeOnMainThread(() => { chatSelectionStack.Children.Add(chatSelectionTile); chatSelctScroll.ScrollToAsync(chatSelectionStack, ScrollToPosition.Start, false); }); OrderMostRecentChat(chatSelectionTile); }
/// <summary> /// Adds the saved Chats to the UI /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ChatSelection_SavedChatAdded(object sender, ChatEventArgs e) { List <Chat> savedChats = e.ChatList; int curruntNummerOfChatSeletionTiles = CurrentChatSelectionTiles().Count; if (savedChats.Count == curruntNummerOfChatSeletionTiles) { return; } else if (savedChats.Count >= curruntNummerOfChatSeletionTiles) { Device.BeginInvokeOnMainThread(() => { foreach (Chat chat in savedChats) { ChatPage chatPage = new ChatPage(chat); ChatSelectionTile chatSelectionTile = new ChatSelectionTile(chatPage); chatSelectionStack.Children.Add(chatSelectionTile); } }); return; } else if (savedChats.Count <= curruntNummerOfChatSeletionTiles) { Device.BeginInvokeOnMainThread(() => { foreach (Chat chat in savedChats) { ChatPage chatPage = new ChatPage(chat); ChatSelectionTile chatSelectionTile = new ChatSelectionTile(chatPage); chatSelectionStack.Children.Add(chatSelectionTile); } }); } App.SaveData = GetChatsCurrentChats(); }