// Initialize Stuff public async void Initialize() { BackgroundTaskUtils.RegisterToastNotificationBackgroundTasks(); ContactUtils.AssignAppToPhoneContacts(); _store = await ChatMessageManager.RequestStoreAsync(); ChatConversations = await GetChats(); if (ChatConversations.Count != 0) { SelectedItem = ChatConversations[0]; } if (!(await PerformMandatoryChecks())) { await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async() => { await new CellularUnavailableContentDialog().ShowAsync(); }); } _store.ChangeTracker.Enable(); _store.StoreChanged += Store_StoreChanged; }
public EnterNumber() { InitializeComponent(); //this.Loaded += new RoutedEventHandler(EnterNumberPage_Loaded); initializeCountryCodes(); appBar = new ApplicationBar(); appBar.Mode = ApplicationBarMode.Default; appBar.Opacity = 1; appBar.IsVisible = true; appBar.IsMenuEnabled = false; nextIconButton = new ApplicationBarIconButton(); nextIconButton.IconUri = new Uri("/View/images/icon_next.png", UriKind.Relative); nextIconButton.Text = AppResources.AppBar_Next_Btn; nextIconButton.Click += new EventHandler(enterPhoneBtn_Click); nextIconButton.IsEnabled = false; appBar.Buttons.Add(nextIconButton); enterNumber.ApplicationBar = appBar; this.countryList.ItemsSource = GetGroupedList(); if (!App.appSettings.Contains(ContactUtils.IS_ADDRESS_BOOK_SCANNED) && ContactUtils.ContactState == ContactUtils.ContactScanState.ADDBOOK_NOT_SCANNING) { ContactUtils.getContacts(new ContactUtils.contacts_Callback(ContactUtils.contactSearchCompleted_Callback)); } }
private void MenuItem_Tap_AddUser(object sender, System.Windows.Input.GestureEventArgs e) { if (!NetworkInterface.GetIsNetworkAvailable()) { MessageBoxResult result = MessageBox.Show(AppResources.Please_Try_Again_Txt, AppResources.No_Network_Txt, MessageBoxButton.OK); return; } ListBoxItem selectedListBoxItem = this.groupChatParticipants.ItemContainerGenerator.ContainerFromItem((sender as MenuItem).DataContext) as ListBoxItem; if (selectedListBoxItem == null) { return; } gp_obj = selectedListBoxItem.DataContext as GroupParticipant; if (gp_obj == null) { return; } if (!gp_obj.Msisdn.Contains(gp_obj.Name)) // shows name is already stored so return { return; } ContactInfo ci = UsersTableUtils.getContactInfoFromMSISDN(gp_obj.Msisdn); if (ci != null) { return; } ContactUtils.saveContact(gp_obj.Msisdn, new ContactUtils.contactSearch_Callback(saveContactTask_Completed)); }
public WelcomePage() { InitializeComponent(); App.createDatabaseAsync(); appBar = new ApplicationBar(); appBar.Mode = ApplicationBarMode.Default; appBar.Opacity = 1; appBar.IsVisible = true; nextIconButton = new ApplicationBarIconButton(); nextIconButton.IconUri = new Uri("/View/images/icon_next.png", UriKind.Relative); nextIconButton.Text = AppResources.WelcomePage_Accept_AppBar; nextIconButton.Click += new EventHandler(getStarted_click); appBar.Buttons.Add(nextIconButton); welcomePage.ApplicationBar = appBar; // if addbook is not scanned and state is not scanning if (!App.appSettings.Contains(ContactUtils.IS_ADDRESS_BOOK_SCANNED) && ContactUtils.ContactState == ContactUtils.ContactScanState.ADDBOOK_NOT_SCANNING) { ContactUtils.getContacts(new ContactUtils.contacts_Callback(ContactUtils.contactSearchCompleted_Callback)); } //if (!App.IS_MARKETPLACE) //{ // signupPanel.Tap += signupPanel_Tap; // serverTxtBlk.Visibility = System.Windows.Visibility.Visible; // if(!AccountUtils.IsProd) // serverTxtBlk.Text = "staging"; // else // serverTxtBlk.Text = "production"; //} }
public FileContentResult ContactExport(string keyword = null, string firstName = null, string middleName = null, string lastName = null, string department = null, string fax = null, string email = null, string phone = null, string mobile = null, string OHIMOwnerID = null, string OHIMNumTrademarks = null) { var query = ContactUtils.BuildExportQuery(keyword ?? firstName, middleName, lastName, department, fax, email, phone, mobile, OHIMOwnerID, OHIMNumTrademarks); var file = this._managementContactService.ExportByQuery(query); return(File(new UTF8Encoding().GetBytes(file.ToString()), "text/csv", $"Export-Contact-{StringUtils.GetCurrentDateTimeAsString()}.csv")); }
// Methods private async Task <Contact> GetContactInformation() { var msg = await _store.GetMessageAsync(_messageid); if (!msg.IsIncoming) { return(await ContactUtils.GetMyself()); } return(await ContactUtils.BindPhoneNumberToGlobalContact(msg.From)); }
public static void SendEmail(MailMessage Message) { try { ContactUtils.SendMail(Message); } catch (Exception ex) { Logger.HandleError(ex, nameof(SendEmail)); } }
private async void HandleArguments(ToastNotificationActivatedEventArgs args) { string arguments = args.Argument; string action = args.Argument.Split('&').First(x => x.ToLower(new CultureInfo("en-US")).StartsWith("action=", StringComparison.InvariantCulture)).Split('=')[1]; string from = args.Argument.Split('&').First(x => x.ToLower(new CultureInfo("en-US")).StartsWith("from=", StringComparison.InvariantCulture)).Split('=')[1]; string deviceid = args.Argument.Split('&').First(x => x.ToLower(new CultureInfo("en-US")).StartsWith("deviceid=", StringComparison.InvariantCulture)).Split('=')[1]; switch (action.ToLower(new CultureInfo("en-US"))) { case "reply": { try { string messagetosend = (string)args.UserInput["textBox"]; SmsDevice2 smsDevice = SmsDevice2.FromId(deviceid); await SmsUtils.SendTextMessageAsync(smsDevice, from, messagetosend); } catch { } break; } case "openthread": { ChatMenuItemControl selectedConvo = null; foreach (var convo in ViewModel.ChatConversations) { var contact = convo.ViewModel.Contact; foreach (var num in contact.Phones) { if (ContactUtils.ArePhoneNumbersMostLikelyTheSame(from, num.Number)) { selectedConvo = convo; break; } } if (selectedConvo != null) { break; } } if (selectedConvo != null) { ViewModel.SelectedItem = selectedConvo; } break; } } }
private void saveContactTask_Completed(object sender, SaveContactResult e) { switch (e.TaskResult) { case TaskResult.OK: ContactUtils.getContact(gp_obj.Msisdn, new ContactUtils.contacts_Callback(contactSearchCompleted_Callback)); break; case TaskResult.Cancel: MessageBox.Show(AppResources.User_Cancelled_Task_Txt); break; case TaskResult.None: MessageBox.Show(AppResources.NoInfoForTask_Txt); break; } }
private void registerPostResponse_Callback(JObject obj) { Uri nextPage = null; if ((obj == null)) { //logger.Info("HTTP", "Unable to create account"); Deployment.Current.Dispatcher.BeginInvoke(() => { NetworkErrorTxtBlk.Opacity = 1; progressBar.Opacity = 0; progressBar.IsEnabled = false; nextIconButton.IsEnabled = true; }); isClicked = false; return; } /* This case is when you are on wifi and need to go to fallback screen to register.*/ if (HikeConstants.FAIL == (string)obj[HikeConstants.STAT]) { nextPage = new Uri("/View/EnterNumber.xaml", UriKind.Relative); } /* account creation successfull */ else { utils.Utils.savedAccountCredentials(obj); if (App.MSISDN.StartsWith("+91")) { App.WriteToIsoStorageSettings(App.COUNTRY_CODE_SETTING, "+91"); } nextPage = new Uri("/View/EnterName.xaml", UriKind.Relative); /* scan contacts and post addressbook on server*/ ContactUtils.getContacts(new ContactUtils.contacts_Callback(ContactUtils.contactSearchCompleted_Callback)); } /*This is used to avoid cross thread invokation exception*/ Deployment.Current.Dispatcher.BeginInvoke(() => { NavigationService.Navigate(nextPage); progressBar.Opacity = 0; progressBar.IsEnabled = false; }); }
private void contactShared_Click(object sender, System.Windows.Input.GestureEventArgs e) { contactInfoObj = contactsListBox.SelectedItem as ContactInfo; if (contactInfoObj == null) { return; } MessageBoxResult mr = MessageBox.Show(string.Format(AppResources.ShareContact_ConfirmationText, contactInfoObj.Name), AppResources.ShareContact_ConfirmationCaption, MessageBoxButton.OKCancel); if (mr == MessageBoxResult.OK) { string searchNumber = contactInfoObj.Msisdn; string country_code = null; if (App.appSettings.TryGetValue(App.COUNTRY_CODE_SETTING, out country_code)) { searchNumber = searchNumber.Replace(country_code, ""); } ContactUtils.getContact(searchNumber, contactSearchCompleted_Callback); } }
private void btnGetSelected_Tap(object sender, System.Windows.Input.GestureEventArgs e) { groupChatParticipants.SelectedIndex = -1; gp_obj = (sender as ListBox).SelectedItem as GroupParticipant; if (gp_obj == null) { return; } if (!gp_obj.Msisdn.Contains(gp_obj.Name)) // shows name is already stored so return { return; } ContactInfo ci = UsersTableUtils.getContactInfoFromMSISDN(gp_obj.Msisdn); if (ci != null) { return; } ContactUtils.saveContact(gp_obj.Msisdn, new ContactUtils.contactSearch_Callback(saveContactTask_Completed)); }
private async Task <(Contact, string)> GetContactInformation() { try { var convo = await _store.GetConversationAsync(_conversationid); var contact = await ContactUtils.BindPhoneNumberToGlobalContact(convo.Participants.First()); return(contact, contact.DisplayName); } catch { Contact blankcontact = new Contact(); blankcontact.Phones.Add(new ContactPhone() { Number = "Unknown", Kind = ContactPhoneKind.Other }); return(blankcontact, "Unknown"); } }
private void refreshContacts_Click(object sender, EventArgs e) { App.AnalyticsInstance.addEvent(Analytics.REFRESH_CONTACTS); if (!NetworkInterface.GetIsNetworkAvailable()) { MessageBoxResult result = MessageBox.Show(AppResources.Please_Try_Again_Txt, AppResources.No_Network_Txt, MessageBoxButton.OK); return; } disableAppBar(); if (progressIndicator == null) { progressIndicator = new ProgressIndicatorControl(); } progressIndicator.Show(LayoutRoot, AppResources.SelectUser_RefreshWaitMsg_Txt); canGoBack = false; ContactUtils.getContacts(new ContactUtils.contacts_Callback(makePatchRequest_Callback)); }
private async void Load() { var participant = ChatConversation.Participants.First(); var contact = await ContactUtils.BindPhoneNumberToGlobalContact(participant); var messageReader = ChatConversation.GetMessageReader(); var lastMessageId = ChatConversation.MostRecentMessageId; var messages = await messageReader.ReadBatchAsync(); var lastMessage = messages.Where(x => x.Id == lastMessageId).First(); DisplayMessage = lastMessage.Body; DisplayDate = lastMessage.LocalTimestamp.LocalDateTime.ToString(); Contact = contact; DisplayName = contact.DisplayName; ChatName.Text = DisplayName; ChatDate.Text = DisplayDate; PeoplePic.Contact = Contact; ChatContent.Text = DisplayMessage; }
private async void Load() { BackgroundTaskUtils.RegisterToastNotificationBackgroundTasks(); ContactUtils.AssignAppToPhoneContacts(); ChatMessageStore store = await ChatMessageManager.RequestStoreAsync(); var reader = store.GetConversationReader(); var convos = await reader.ReadBatchAsync(); bool initializedonce = false; foreach (var convo in convos) { NavigationView.MenuItems.Add(new ChatMenuItemControl(convo)); if (!initializedonce) { NavigationView.SelectedItem = NavigationView.MenuItems[0]; } initializedonce = true; } }
public ActionResult Contact(int rowCount = 25, int page = 1, string keyword = null, string firstName = null, string middleName = null, string lastName = null, string department = null, string fax = null, string email = null, string phone = null, string mobile = null, string OHIMOwnerID = null, string OHIMNumTrademarks = null) { var searchResultObject = new VMSearchResultObject <Contact> { Caption = "Contact" }; var startIndex = (page - 1) * rowCount; var query = ContactUtils.BuildQuery(startIndex, rowCount, keyword ?? firstName, middleName, lastName, department, fax, email, phone, mobile, OHIMOwnerID, OHIMNumTrademarks); var contacts = this._managementContactService.GetByQuery(query.Item1, query.Item2, out int total); searchResultObject.ObjectResult = new VMPageResult <Contact> { StartIndex = startIndex, RowCount = rowCount, Page = page, Total = total, Records = contacts }; if (!string.IsNullOrWhiteSpace(keyword)) { var searchResultWrapperList = this._searchService.Search(firstName ?? keyword); searchResultObject.SearchResult = new VMSearchResult { Table = searchResultWrapperList }; } ViewBag.Keyword = keyword ?? firstName; ViewBag.IsAdvanceSearch = string.IsNullOrWhiteSpace(keyword); return(View(searchResultObject)); }
protected override async void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); var args = e.Parameter as ChatConversation; if (args != null) { convo = args; } var contact = await ContactUtils.BindPhoneNumberToGlobalContact(convo.Participants.First()); ConvoTitle.Text = contact.DisplayName; ConvoPic.Contact = contact; var reader = convo.GetMessageReader(); var messages = await reader.ReadBatchAsync(); messages.ToList().ForEach(x => observableCollection.Insert(0, new ChatMessageViewControl(x))); Load(); }
/* This callback is on background thread started by getContacts function */ public void makePatchRequest_Callback(object sender, ContactsSearchEventArgs e) { if (stopContactScanning) { stopContactScanning = false; return; } Dictionary <string, List <ContactInfo> > new_contacts_by_id = ContactUtils.getContactsListMap(e.Results); Dictionary <string, List <ContactInfo> > hike_contacts_by_id = ContactUtils.convertListToMap(UsersTableUtils.getAllContacts()); /* If no contacts in Phone as well as App , simply return */ if ((new_contacts_by_id == null || new_contacts_by_id.Count == 0) && hike_contacts_by_id == null) { scanningComplete(); canGoBack = true; return; } Dictionary <string, List <ContactInfo> > contacts_to_update_or_add = new Dictionary <string, List <ContactInfo> >(); if (new_contacts_by_id != null) // if there are contacts in phone perform this step { foreach (string id in new_contacts_by_id.Keys) { List <ContactInfo> phList = new_contacts_by_id[id]; if (hike_contacts_by_id == null || !hike_contacts_by_id.ContainsKey(id)) { contacts_to_update_or_add.Add(id, phList); continue; } List <ContactInfo> hkList = hike_contacts_by_id[id]; if (!ContactUtils.areListsEqual(phList, hkList)) { contacts_to_update_or_add.Add(id, phList); } hike_contacts_by_id.Remove(id); } new_contacts_by_id.Clear(); new_contacts_by_id = null; } /* If nothing is changed simply return without sending update request*/ if (contacts_to_update_or_add.Count == 0 && (hike_contacts_by_id == null || hike_contacts_by_id.Count == 0)) { Thread.Sleep(1000); scanningComplete(); canGoBack = true; return; } JArray ids_to_delete = new JArray(); if (hike_contacts_by_id != null) { foreach (string id in hike_contacts_by_id.Keys) { ids_to_delete.Add(id); } } ContactUtils.contactsMap = contacts_to_update_or_add; ContactUtils.hike_contactsMap = hike_contacts_by_id; App.MqttManagerInstance.disconnectFromBroker(false); NetworkManager.turnOffNetworkManager = true; /* * contacts_to_update : These are the contacts to add * ids_json : These are the contacts to delete */ if (stopContactScanning) { stopContactScanning = false; return; } AccountUtils.updateAddressBook(contacts_to_update_or_add, ids_to_delete, new AccountUtils.postResponseFunction(updateAddressBook_Callback)); }
public static FileAsMapping GetDefaultFileAs() { return(ContactUtils.GetDefaultFileAs(Culture.GetUserCulture().LCID)); }
private async Task DisplayToast(IBackgroundTaskInstance taskInstance) { try { SmsMessageReceivedTriggerDetails smsDetails = taskInstance.TriggerDetails as SmsMessageReceivedTriggerDetails; string deviceid = ""; string body = ""; string from = ""; ContactUtils.ContactInformation information = new ContactUtils.ContactInformation(); switch (smsDetails.MessageType) { case SmsMessageType.Text: { SmsTextMessage2 smsTextMessage = smsDetails.TextMessage; body = smsTextMessage.Body; deviceid = smsTextMessage.DeviceId; from = smsTextMessage.From; information = await ContactUtils.FindContactInformationFromSmsMessage(smsTextMessage); break; } /*case SmsMessageType.Wap: * { * SmsWapMessage smsWapMessage = smsDetails.WapMessage; * body = "[DEBUG - Report if seen] " + smsWapMessage.ContentType + " - " + "Wap"; * deviceid = smsWapMessage.DeviceId; * from = smsWapMessage.From; * information = await ContactUtils.FindContactInformationFromSmsMessage(smsWapMessage); * break; * } * case SmsMessageType.App: * { * SmsAppMessage smsAppMessage = smsDetails.AppMessage; * body = "[DEBUG - Report if seen] " + smsAppMessage.Body + " - RAW: " + BitConverter.ToString(smsAppMessage.BinaryBody.ToArray()) + " - " + "App"; * deviceid = smsAppMessage.DeviceId; * from = smsAppMessage.From; * information = await ContactUtils.FindContactInformationFromSmsMessage(smsAppMessage); * break; * } * case SmsMessageType.Status: * { * SmsStatusMessage smsStatusMessage = smsDetails.StatusMessage; * body = "[DEBUG - Report if seen] " + smsStatusMessage.Body + " - " + smsStatusMessage.Status.ToString() + " - " + "Status"; * deviceid = smsStatusMessage.DeviceId; * from = smsStatusMessage.From; * information = await ContactUtils.FindContactInformationFromSmsMessage(smsStatusMessage); * break; * }*/ default: return; } var toastContent = new ToastContent() { Visual = new ToastVisual() { BindingGeneric = new ToastBindingGeneric() { Children = { new AdaptiveText() { Text = information.DisplayName, HintMaxLines = 1 }, new AdaptiveText() { Text = body } }, AppLogoOverride = new ToastGenericAppLogo() { Source = information.ThumbnailPath, HintCrop = ToastGenericAppLogoCrop.Circle }, Attribution = new ToastGenericAttributionText() { Text = information.PhoneNumberKind } } }, Actions = new ToastActionsCustom() { Inputs = { new ToastTextBox("textBox") { PlaceholderContent = "Type a message" } }, Buttons = { new ToastButton("Send", $"action=reply&from={from}&deviceid={deviceid}") { ActivationType = ToastActivationType.Background, ImageUri = "Assets/ToastIcons/Send.png", TextBoxId = "textBox" } } }, Launch = $"action=openThread&from={from}&deviceid={deviceid}", Audio = new ToastAudio() { Src = new Uri("ms-winsoundevent:Notification.SMS") } }; var toastNotif = new ToastNotification(toastContent.GetXml()); ToastNotificationManager.CreateToastNotifier().Show(toastNotif); try { BadgeHandler.IncreaseBadgeNumber(); } catch { } smsDetails.Accept(); } catch { } }
protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e) { base.OnNavigatedTo(e); while (NavigationService.CanGoBack) { NavigationService.RemoveBackEntry(); } if (isFirstLaunch) { PushHelper.Instance.registerPushnotifications(); string msisdn = (string)App.appSettings[App.MSISDN_SETTING]; msisdn = msisdn.Substring(msisdn.Length - 10); StringBuilder userMsisdn = new StringBuilder(); userMsisdn.Append(msisdn.Substring(0, 3)).Append("-").Append(msisdn.Substring(3, 3)).Append("-").Append(msisdn.Substring(6)).Append("!"); string country_code = null; App.appSettings.TryGetValue <string>(App.COUNTRY_CODE_SETTING, out country_code); txtBlckPhoneNumber.Text = " " + (country_code == null ? "+91" : country_code) + "-" + userMsisdn.ToString(); if (!App.appSettings.Contains(ContactUtils.IS_ADDRESS_BOOK_SCANNED)) { if (ContactUtils.ContactState == ContactUtils.ContactScanState.ADDBOOK_NOT_SCANNING) { ContactUtils.getContacts(new ContactUtils.contacts_Callback(ContactUtils.contactSearchCompleted_Callback)); } BackgroundWorker bw = new BackgroundWorker(); bw.DoWork += (ss, ee) => { while (ContactUtils.ContactState != ContactUtils.ContactScanState.ADDBOOK_SCANNED) { Thread.Sleep(100); } // now addressbook is scanned Debug.WriteLine("Posting addbook from thread 1.... "); string token = (string)App.appSettings["token"]; AccountUtils.postAddressBook(ContactUtils.contactsMap, new AccountUtils.postResponseFunction(postAddressBook_Callback)); }; bw.RunWorkerAsync(); } isFirstLaunch = false; } txtBxEnterName.Hint = AppResources.EnterName_Name_Hint; if (App.IS_TOMBSTONED) /* **************************** HANDLING TOMBSTONE *************************** */ { object obj = null; if (this.State.TryGetValue("txtBxEnterName", out obj)) { txtBxEnterName.Text = (string)obj; txtBxEnterName.Select(txtBxEnterName.Text.Length, 0); obj = null; } if (this.State.TryGetValue("nameErrorTxt.Visibility", out obj)) { nameErrorTxt.Visibility = (Visibility)obj; nameErrorTxt.Text = (string)this.State["nameErrorTxt.Text"]; } } if (PhoneApplicationService.Current.State.ContainsKey("fbName")) { string name = PhoneApplicationService.Current.State["fbName"] as string; txtBxEnterName.Text = name; txtBxEnterName.Hint = string.Empty; nextIconButton.IsEnabled = true; } if (reloadImage) // this will handle both deactivation and tombstone { if (PhoneApplicationService.Current.State.ContainsKey("img")) { _avatar = (byte[])PhoneApplicationService.Current.State["img"]; reloadImage = false; } else { _avatar = MiscDBUtil.getThumbNailForMsisdn(HikeConstants.MY_PROFILE_PIC); } if (_avatar != null) { try { MemoryStream memStream = new MemoryStream(_avatar); memStream.Seek(0, SeekOrigin.Begin); BitmapImage empImage = new BitmapImage(); empImage.SetSource(memStream); avatarImage.Source = empImage; } catch { avatarImage.Source = UI_Utils.Instance.getDefaultAvatar((string)App.appSettings[App.MSISDN_SETTING]); } } else { avatarImage.Source = UI_Utils.Instance.getDefaultAvatar((string)App.appSettings[App.MSISDN_SETTING]); } } }
private async Task DisplayToast(IBackgroundTaskInstance taskInstance) { try { SmsMessageReceivedTriggerDetails smsDetails = taskInstance.TriggerDetails as SmsMessageReceivedTriggerDetails; SmsTextMessage2 smsTextMessage; string deviceid = ""; if (smsDetails.MessageType == SmsMessageType.Text) { smsTextMessage = smsDetails.TextMessage; deviceid = smsTextMessage.DeviceId; var information = await ContactUtils.FindContactInformationFromSmsTextMessage(smsTextMessage); var toastContent = new ToastContent() { Visual = new ToastVisual() { BindingGeneric = new ToastBindingGeneric() { Children = { new AdaptiveText() { Text = information.DisplayName, HintMaxLines = 1 }, new AdaptiveText() { Text = smsTextMessage.Body } }, AppLogoOverride = new ToastGenericAppLogo() { Source = information.ThumbnailPath, HintCrop = ToastGenericAppLogoCrop.Circle }, Attribution = new ToastGenericAttributionText() { Text = information.PhoneNumberKind } } }, Actions = new ToastActionsCustom() { Inputs = { new ToastTextBox("textBox") { PlaceholderContent = "Send a message" } }, Buttons = { new ToastButton("Send", "action=reply" + "&from=" + smsTextMessage.From + "&deviceid=" + deviceid) { ActivationType = ToastActivationType.Background, ImageUri = "Assets/ToastIcons/Send.png", TextBoxId = "textBox" } } }, Launch = "action=openThread" + "&from=" + smsTextMessage.From + "&deviceid=" + deviceid, Audio = new ToastAudio() { Src = new Uri("ms-winsoundevent:Notification.SMS") } }; var toastNotif = new ToastNotification(toastContent.GetXml()); ToastNotificationManager.CreateToastNotifier().Show(toastNotif); try { BadgeHandler.IncreaseBadgeNumber(); } catch { } } smsDetails.Accept(); } catch { } }
private async Task DisplayToast(ChatMessage message) { var information = await ContactUtils.FindContactInformationFromSender(message.From); string thumbnailpath = ""; string text = ""; string deviceid = SmsDevice2.GetDefault().DeviceId; foreach (var attachment in message.Attachments) { try { //extra += " " + attachment.MimeType; if (attachment.MimeType == "application/smil") { } if (attachment.MimeType == "text/vcard") { text += "Contact content in this message. "; } if (attachment.MimeType.StartsWith("image/")) { text += "Image content in this message. "; var imageextension = attachment.MimeType.Split('/').Last(); thumbnailpath = await SaveFile(attachment.DataStreamReference, "messagepicture." + DateTimeOffset.Now.ToUnixTimeMilliseconds() + "." + imageextension); } if (attachment.MimeType.StartsWith("audio/")) { text += "Audio content in this message. "; var audioextension = attachment.MimeType.Split('/').Last(); } } catch { //extra += " oops"; } } var toastContent = new ToastContent() { Visual = new ToastVisual() { BindingGeneric = new ToastBindingGeneric() { Children = { new AdaptiveText() { Text = information.DisplayName, HintMaxLines = 1 }, new AdaptiveText() { Text = string.IsNullOrEmpty(message.Body) ? text : message.Body } }, HeroImage = new ToastGenericHeroImage() { Source = thumbnailpath }, AppLogoOverride = new ToastGenericAppLogo() { Source = information.ThumbnailPath, HintCrop = ToastGenericAppLogoCrop.Circle }, Attribution = new ToastGenericAttributionText() { Text = information.PhoneNumberKind //+ " " + extra } } }, Actions = new ToastActionsCustom() { Inputs = { new ToastTextBox("textBox") { PlaceholderContent = "Send a message" } }, Buttons = { new ToastButton("Send", "action=reply" + "&from=" + message.From + "&deviceid=" + deviceid) { ActivationType = ToastActivationType.Background, ImageUri = "Assets/ToastIcons/Send.png", TextBoxId = "textBox" } } }, Launch = "action=openThread" + "&from=" + message.From + "&deviceid=" + deviceid, Audio = new ToastAudio() { Src = new Uri("ms-winsoundevent:Notification.SMS") } }; var toastNotif = new ToastNotification(toastContent.GetXml()); ToastNotificationManager.CreateToastNotifier().Show(toastNotif); }