This may seem like an odd question, but is there a way to send a local toast notification from a Windows 8 Store App to the machine--and NOT show it on the screen? I have a background task that needs to send a sync request to the UI thread. I have been searching for the better part of 8 hours trying to get different methods to work--and it comes down to this will work for me, but I don't want the request text to show up on the screen when I call it.
I should also add that Toast Notifications WILL be used in the app, so I can't simply turn it off globally, I need only the ones I specify to not show up, to be hidden. Is this possible?
Ideally, I would rather do a Raw Notification, but I can't figure out how to do a local Raw Notification (of if its even possible to simulate it without hitting my API.).
EDIT: Root Problem
My background task is doing work behind the scenes every 15 minutes--to basically send a sync request to the main app. The OnPushNotificationReceived, should capture this and perform a full sync of all data I need: Such as GPS coordinates, checking if "ToDoItems" are nearing due dates and need to be escalated in priority, etc. Among other things, such as checking if there are any documents on the local file system that have been marked as complete and need to be uploaded to Azure file storage, etc.
The answer might be in the OnPushNotificationReceived(PushNotificationChannel sender, PushNotificationReceivedEventArgs args)
args.Cancel = true
From MSDN: https://msdn.microsoft.com/en-us/library/br241295
Cancel:
Read/write Gets or sets whether Windows should perform its default handling of the notification.
You receive the notification and process it in your OnPushNotificationReceived listener, set the cancel to true and voila!
Basically you already processed the notification, so you cancel the default behaviour that is showing the notification.
EDIT CONTENT:
The Raw Notification basically is an empty envelope where you can put any content in any form you want, could be an object, an image, a dictionary... Basically you decide the content to send and obviously the app must know the datamodel to be able to process it.
To create Notifications easily I recommend you this Nuget Package: https://github.com/WindowsNotifications/NotificationsExtensions/tree/master/Windows%208.1%20RT
Example on how to create a toast notifcation:
var toastNoti = ToastContentFactory.CreateToastText02();
toastNoti.TextHeading.Text = "TEXT IN BOLD";
toastNoti.TextBodyWrap.Text = "TEXT IN NORMAL CASE ";
toastNoti.Launch = "NOTIFICATION ARGUMENTS";
var doc = new XmlDocument();
doc.LoadXml(toastNoti.ToString());
var endNotification = new ToastNotification(doc);
endNotification.Tag = "1";
ToastNotificationManager.CreateToastNotifier().Show(endNotification);
Hope this helps. Tell us any result please.
Related
Im trying to check the content of a toast message using playwright but cant find a suitable way to acheive this.
The playwright documentation lists a suitable way to handle alert messages with which I have been able to do things like retrieve the text content from an alert before dismissing it. For example:
Page.Dialog += (_, dialog) =>
{
alertMessage = dialog.Message;
Console.WriteLine(alertMessage);
dialog.AcceptAsync();
};
prints the alert text content prior to accepting the dialog. This can be extended to perform checks such as asserts etc
I've tried using the same approach when trying to handle the toast message but this doesn't work for me, presumably due to different nature of the toast message.
Has anyone successfully managed to interrogate toast messages using playwright?
There is no official documentation from playwright on how to handle toast messages.
Handling Toast Messages in Automation:
Toast messages are normal html elements within the page(not in alert) however they are special in sense as they appear for a very short time and then disappear so we need to write automation code and handle accordingly. Example Below:
async clickSave() {
await Promise.all([
this.page.waitForSelector(loadPanel),
this.page.click(btn_Save),
this.page.waitForSelector('div[class*="ajs-success"]',{state: 'attached'}) //Toast Success message on save successfully
]);
}
now, I'm developing some notification app about the online contest.
image:
I managed to get HttpResponse, and parse it to my Class, and add my app as a startup program.
the problem is that I can't find a good way to How notify my app user.
yesterday, I founded Appointment class and I used it. but always, Appointment should be accepted by user's hand. and It is quite slow, and sometime it crashed.
while (mys.Count != 0)
{
Contest contest = mys.Pop();
var appointment = new Appointment();
appointment.Location = "Codeforces";
appointment.Subject = contest.name;
appointment.StartTime = contest.startDate;
appointment.Reminder = TimeSpan.FromHours(1);
var rect = new Rect();
string tmp = await AppointmentManager.ShowAddAppointmentAsync(appointment, rect);
list.Add(contest); //<- observable collection
}
so I changed my mind to use toast notification class. because I think it doesn't need to be accepted by user.
the main question is"
I wonder how can i push notification about the events which will be held in several days.
I mean
my App user just once execute my App.
my App Queried to website, and get some event. (I did {1, 2})
for all appropriate event, I want to push all event to Toast Notification that is valid after my App is closed or my Computer re-boot.
I downloaded Karaoke one App from MS Store, and it pushes Notification periodically 24 hours, even it has no background process(I think), and even I never execute app after rebooting.
below image is Karaoke one App Notification.
How can i Implement it?.
Thanks for read.
I am using the following libraries to connect a bot to a Google Pub/Sub endpoint to perform a simple reply to a card click event.
Google.Apis.HangoutsChat.v1 1.34.0.1233
Google.Cloud.PubSub.V1 1.0.0-beta18
When I construct my card, everything looks normal in the UI, including the button that is supposed to raise the event.
The topic and subscription contain the default settings, following the guide here
I found the following information from the Google documentation about retries here
Responding synchronously
A bot can respond to an event synchronously by returning a
JSON-formatted message payload in the HTTP response. The deadline for
a synchronous response is 30 seconds.
A synchronous response from a bot is always posted in the thread that
generated the event to the bot.
After clicking the button, my subscriber receives 3 duplicate events. The events have the correct response with all of the right metadata, but are exact duplicates of each other, including the id of the message itself.
I don't feel there is a necessarily large delay in the response of the bot (it should happen in <1 second for this test), so I am not sure why these messages are being duplicated.
I've also tried setting the thread id for the card when responding (via the Thread property itself, or the ThreadKey property), but I always seem to get a new thread id when I post a message.
var cardMessage = MessageSender.Spaces.Messages.Create(new Message()
{
Space = new Space()
{
Name = inReplyToThisMessage.Space.Name
},
Thread = new Thread()
{
Name = inReplyToThisMessage.Thread.Name
},
Cards = new List<Card>()
{
card
},
}, inReplyToThisMessage.Space.Name);
var sendCardResult = await cardMessage.ExecuteAsync().ConfigureAwait(false);
//Thread id of sendCardResult does not match inReplyToThisMessage.Thread.Name no matter what
Interestingly enough, trying to create a new message in response to the click event causes the bot to display a "Unable to connect to bot. Try again later", but displays 3 new messages. Also, when specifying an arbitrary thread key, this key is never echoed back in the bot's response.
Make sure you are returning the main event method properly. What looks to be happening is that you are making an asynchronous call to the chat, but then the chat is looking for a response from the actual event method itself. Google will traditionally try three times before giving up (even if it doesn't take thirty seconds)
If you are indeed returning the event call correctly after you made your api request, then there is something in your code that is causing the Google Bot to think it is not getting a response, so it tries three times. Since the issue could be multi-faceted I would need to look at how you are accepting and returning the click response.
This bug has finally been fixed by Google.
I have some problem with web push notification.
I'm able to send the notification regularly, but, when I send two notification and the first is still visible on the screen, the second overwrite the first one.
The REST API is called by an MVC site written with C#, the object I send is the following:
var obj = new
{
app_id = _appKey,
contents = new { en = message },
headings = new { en = title },
included_segments = new[] { "All" },
url,
chrome_web_icon = imageUrl,
priority = 1,
id = DateTime.Now.ToString("yyyyMMddHHmmss")
};
Did anyone experienced the same issue?
How can I solve that?
Got this answer from OneSignal person.
When using our REST API to programmatically send notifications, you can use the undocumented parameter web_push_topic.
In a set of notifications sharing the same web_push_topic, newly received notifications will replace older received notifications with the same topic. Only notifications sharing the same topic will be replaced; notifications without a topic or with a different topic will not be replaced. You can set different topics for different sets of notifications to control which notifications stay on screen.
The web_push_topic value can be any string value.
On Chrome, a maximum of 3 notifications is displayed at any time, even if the other notifications are not related to your site or from OneSignal. This means you can only show 3 categories of notifications to your user, not counting for other notifications that might be displayed at that time.
On Firefox on Windows, many more notifications can be shown at a time (6+).
On Firefox on Mac, and Safari on Mac, only one notification can be shown at a time, even if the other notifications are not related to your site or from OneSignal. Notifications also disappear quickly within 5 seconds and this time is not customizable.
On Chrome/Firefox on Android, multiple notifications can be shown at a time.
If you do not specify web_push_topic , each notification will be replaced by a newer notification. If you do specify web_push_topic, you can choose which notifications will be replaced and which notifications will stack.
When sending a notification using our API, setting a string value for web_push_topic will set the topic for the notification. Any notifications sharing the same topic will replace each other, but any notifications with a different topic won't be replaced.
So suppose you send 4 notifications:
Notification "Open house at 1234 Street at 3 PM this Saturday" with topic 'open-houses'.
Notification "Open house at 1234 Street changed to 4 PM this Saturday" with topic 'open-houses'.
Notification "20 new houses match your criteria in the Seattle, WA" with topic 'general-updates'.
Notification "Find an agent in your area" with topic 'promotional'.
The sequence of notifications observed will be:
Notification #1 shows.
Notification #2 replaces #1 (even if docked in Mac OS X's notification tray).
Notification #3 is shown separately (and if docked in Mac OS X's notification tray, it will use a separate entry).
Notification #4 is also shown separately.
In the end, when the subscriber checks his unread notifications, he will see three total notifications.
Example Code:
payload = {"app_id": "5eb5a37e-b458-11e3-ac11-000c2940e62c",
"include_player_ids": ["6392d91a-b206-4b7b-a620-cd68e32c3a76"],
"contents": {"en": "English Message"},
"web_push_topic": 'Unique for every notification'}
OneSignal intentionally implements notification replacement that results in this behavior.
The reason for this is to avoid cases where a subscriber could end up with up to 100 notifications to dismiss from a single website, which would be a terrible experience for them.
In the future OneSignal may allow you to avoid this limitation, but in most cases we wouldn't recommend doing this differently.
I'm creating a page that get uploaded text files and builds them into multiple PDFs. They are just exports from Excel. Each row in the file corresponds to a new PDF that needs to be created.
Anyway, once the files are uploaded I want to begin processing them, but I don't want the user to have to stay on the page, or even still have their session open. For example they could close the browser and come back 10 minutes later, log in, and the progress information will say like 112/200 files processed or something. It will be a lot quicker than that though.
So two questions really, how can I pass this processing job to something (Handler?Thread?) that will continue to run when the page is closed, and will return as soon as the job has started (so the browser isn't stopped)? Secondly, where can I store this information so that when the user comes back to the page, they can see the current progress.
I realise that I can't use sessions, and since it will be processing about a file a second I don't really want to update a DB every second. Is there some way I can do this? Is it possible?
I solved this by using the link provided by astander above. I simply create an object in the HttpContext.Application to store progress variables, and then Set the method which does my processing inside a new Thread.
// Create the new progress object
BatchProgress bs = new BatchProgress(0);
if(Application["BatchProgress"] != null)
{
// Should never happen
Application["BatchProgress"] = bs;
}
else
{
Application.Add("BatchProgress","bs");
}
//Set up new thread, run batch is the method that does all the processing.
ThreadStart ts = new ThreadStart(RunBatch);
Thread t = new Thread(ts);
t.Start();
It then returns after the thread starts and I can use jQuery to get the Application["BatchProgress"] object at regular intervals. At the end of my thread the BatchProgress object has its status set to "Complete", then when jQuery queries it, it sees the complete status and removes the progress object from the application.