Quick question.
I did this:
myChannel.ShellToastNotificationReceived += new EventHandler<NotificationEventArgs>(myChannel_ShellToastNotificationReceived);
So if I receive a toast notification while the application is in the foreground the myChannel_ShellToastNotificationReceived function should be called. In that function I have:
void myChannel_ShellToastNotificationReceived(object sender, NotificationEventArgs e)
{
Dispatcher.BeginInvoke(() =>
{
ApplicationTitle.Text = "Toast Notification Message Received";
});
}
The problem is that the function is never called and the ApplicationTitle is never changed.
Am I doing anything wrong?
I've found the problem...it seemed that the toast xml that was being sent was well enough formatted so the phone would receive it out of the app but not when it was inside it.
Wrote the xml by "hand" and didn't use xmlWriter and worked.
string toastMessage = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
"<wp:Notification xmlns:wp=\"WPNotification\">" +
"<wp:Toast>" +
"<wp:Text1>" + title + "</wp:Text1>" +
"<wp:Text2>" + message + "</wp:Text2>" +
"</wp:Toast>" +
"</wp:Notification>";
Related
I'm trying to display a toast notification after a timer run out of time.
The notification works on one of my PC's but the other one won't display it. I get no error when I'm debugging it.
I also tried to set something in the Settings>Notifications but in the list of apps which are allowed/not allowed to display notifications I can't see my application.
This is my Notifications Class:
class NewToastNotification
{
public NewToastNotification(string text)
{
string Toast = String.Format("<toast>"+
"<visual>+" +
"<binding template=\"ToastImageAndText04\">" +
"<text id = \"1\" >Toast Test </text>+" +
"<text id = \"2\" >{0}</text>+" +
"<text id = \"2\" >{1}</text>+" +
"</binding>+" +
"</visual>+" +
"</toast>", text, DateTime.Now);
var tileXml = new Windows.Data.Xml.Dom.XmlDocument();
tileXml.LoadXml(Toast);
var toast = new ToastNotification(tileXml);
ToastNotificationManager.CreateToastNotifier("1").Show(toast);
}
}
Use
ToastNotificationManager.CreateToastNotifier().Show(toast);
instead of
ToastNotificationManager.CreateToastNotifier("1").Show(toast);
I have a desktop application written in C#. I want to collect user statistics in google analytics. For instance I want to know when user pressed on specific button and what was value in text control when he did it.
I am sending events data as explained here. I tried to do this either with WebClient.UploadValues like in this question and also with WebClient.UploadString
I have set up new google analytics account. When I was asked what I want to track (website or mobile app) I have selected mobile app (there was no choice for desktop apps).
The problem is that I don't see any data in my Google Analytics account. I know it may take some time while new data will appear there but I have waited for 3 days. And also I don't see anything in real time view when I test my application ( I also have some websites with analytics connected and when I browse them I see new pageviews in realtime section).
What am I doing wrong?
Here is the code that I use:
private static string _googleURL = "http://www.google-analytics.com/collect";
private static string _gaid = "UA-12345678-9";
public static void TestMethod()
{
try
{
string data = "";
data += "v=" + HttpUtility.UrlEncode("1");
data += "&" + "tid" + "=" + HttpUtility.UrlEncode(_gaid);
data += "&" + "cid" + "=" + HttpUtility.UrlEncode(Guid.NewGuid().ToString());
data += "&" + "t" + "=" + HttpUtility.UrlEncode("event");
data += "&" + "ec" + "=" + HttpUtility.UrlEncode("testevent");
data += "&" + "ea" + "=" + HttpUtility.UrlEncode("testaction");
data += "&" + "el" + "=" + HttpUtility.UrlEncode("testlabel");
using (var client = new WebClient())
{
client.UploadString(_googleURL, "POST", data);
}
}
catch (Exception ex)
{
Trace.WriteLine(ex);
}
}
I have some toast notifications with alarm scenario. I used the following toast schema, but when notification is raised, there are no buttons(snooze or dismiss).
Here is my xml content. So why cant i use this toast commands?
var contentString = "<toast duration=\"long\">\n" +
"<visual>\n" +
"<binding template=\"ToastText02\">\n" +
"<text id=\"1\">" + alarmTitle + "</text>\n" +
"<text id=\"2\">" + alarmNote + "</text>\n" +
"</binding>\n" +
"</visual>\n" +
"<commands scenario=\"alarm\">\n" +
"<command id=\"snooze\"/>\n" +
"<command id=\"dismiss\"/>\n" +
"</commands>\n" +
"<audio src=\"ms-winsoundevent:Notification.Looping.Alarm2\"\n" +
"loop=\"true\"/>\n" +
"</toast>\n";
As is normal, Windows Phone 8 RT does not have the all features of Windows Store Apps.
There is a link on the MSDN that says what is not available on WinRT apps.
One of the entries is Alarms and reminders, so sadly you will not be able to use alarms on WP8.1.
I use in my application ScheduledTileNotifications and push 10 until 20 messages in the TileUpdateManager. But on the metro there are only 5 messages active. What can I do to display more than 5 notifications in the metro-Tile?
string tileXmlString = "<tile>"
+ "<visual>"
+ "<binding template='TileWideSmallImageAndText03' branding='name'>"
+ "<image id='1' src='ms-appx:///Assets/icons/cube_for_kachel.png'/>"
+ "<text id='1'>" + longSubject + "\n" + message.title + "</text>"
+ "</binding>"
+ "<binding template='TileSquareText04' branding='name'>"
+ "<text id='1'>" + shortSubject + "\n" + message.title + "</text>"
+ "</binding>"
+ "</visual>"
+ "</tile>";
XmlDocument tileXml = new XmlDocument();
tileXml.LoadXml(tileXmlString);
ScheduledTileNotification sceduleNotification = new ScheduledTileNotification(tileXml, DateTime.Now.AddSeconds(15));
TileUpdateManager.CreateTileUpdaterForApplication().EnableNotificationQueue(true);
TileUpdateManager.CreateTileUpdaterForApplication().AddToSchedule(sceduleNotification);
When I set the EnableNotificationQueue to true, five of my notification run in a circle. When I set it to false, my notification donĀ“t run in a circle. But I have 10 until 20 Notifications, which should run in a circle. Do you think it is possible.
When I use the AddToSchedule method an push 10 Notifications, each notification will show for one time.
The problem is related to the use of the EnableNotificationQueue method. In fact, as you can read at http://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.notifications.tileupdater.enablenotificationqueue:
When queuing is enabled, a maximum of five tile notifications can
automatically cycle on the tile.
Try to pass false to this method.
According to the documentation, you can schedule up to 4096 notifications. Reref to http://hansstan.wordpress.com/2012/09/02/windows-8-advanced-tile-badge-topics/ for a working example.
I would like to append a small message stating how the message to a user was sent when one chooses to use the SMSComposeTask or EmailComposeTask in my application. I would like it to say something like "sent from" + my application name but I am not sure how to navigate to the end of the user's message and then add my text. So far I've just navigated down a couple of lines and added it manually, but I would like to go to the next line and state the message to save the user from possibly sending multiple text messages once the 160 character limit is reached.
MainPage.xaml.cs
private void Messaging_Click(object sender, RoutedEventArgs e) {
SmsComposeTask smsComposeTask = new SmsComposeTask();
smsComposeTask.To = "";
smsComposeTask.Body = "Check out this application!" + "\n\n" + "sent from " + "QuickStarts";
smsComposeTask.Show();
}
private void Email_Click(object sender, RoutedEventArgs e) {
EmailComposeTask emailComposeTask = new EmailComposeTask();
emailComposeTask.Subject = "Share from " + "QuickStarts";
emailComposeTask.Body = "Check out this application!" + "\n\n" + "sent from " + "QuickStarts";
emailComposeTask.To = "";
emailComposeTask.Cc = "";
emailComposeTask.Bcc = "";
emailComposeTask.Show();
}
Once you've shown the SmsComposeTask or the EmailComposeTask, you have no control whichever on what the user will type. The best you can do is showing a textbox in your application so the user can type its message, then append your "sent from" text, doing every check you need, and only then show the task. But the user will still be able to change the message afterward.