UWP Notifications from Background Service - c#

Summary
I want to handle push notifications from a background-service (or an application shown as a tray icon) and show it as a native Notification in the Action Center (priority: Windows, but if it's cross platform, it works aswell).
The tray icon is optional and nice-to-have. The important thing is the application should run in the background and show notifications.
Question
Can you suggest a way to show a native (windows) notification while the application is running in the background? Maybe an overview of the current (read: not deprecated) ways of achieving this?
Details
There seem to be a thousand ways how to handle notifications in Windows and none seem to work flawlessly. UWP doesn't support tray icons (you have to do a hacky-thing with a WinForms application or WPF), Electron seems to work only when you have it as a shortcut to the Start Menu, WinForms is ugly to get to show notifications in the Action Center.
Can you suggest a way of doing this? Preferably without having to submit the application to the Store.
So far, it seems I will have to deploy a Notification Service on Azure, but I am not sure my application can handle these notifications while it is in the background.
JetBrains Toolbox provides a similar approach I want to accomplish: It is in the tray and can send notifications (like when I search for an update).

Related

Notification icon and balloon messages in c# cross-platform

I'm going to develop a desktop application which is a sort of background service listening for events. The requirements for this application are:
tray icon in background always visible
show up notifications on desktop when an event occurs (like receive an email such as, you will notify with a popup)
The main problem is that the application must run under Windows,Mac and Linux.
I decided to develop the main business logic in .NET Core, but I have a few problems about the front-end part; using Windows.Forms.NotifyIcon it's easy, but obviously this solution isn't valid for other platforms.
So, I found GtkSharp project, in particular the StatusIcon object seems to do exactly what I need, except for the notification part. What I need is a sort of balloon info which is already part of Windows.Forms.NotifyIcon, but not in Gtk. Does anyone know if there is a library or a component that allow me to achieve my requirements for a cross-platform context?
[UPDATE]
I asked directly in GtkSharp channel and they told me that is not possible do what I need with GtkSharp (moreover StatusIcon is deprecated and removed from GTK 4).
I found another interesting possible way, seems that Electron framework support all my requirements. Is a different approch, but it covers all what I need and works well on MacOs,Windows and Linux.

DwmRegisterThumbnail for UWP app

I'm working on a UWP app that provides task-switching capabilities for users with complex physical limitations. This question is related to trying to provide the live thumbnails like alt-tab and the taskbar do. So far, much of the functionality has been made possible through an in-process full-trust component making the necessary (winapi) calls and passing information back to the UWP app.
I made a test WPF app utilizing DwmRegisterThumbnail and DwmUpdateThumbnailProperties and it works fine.
However, when I attempt to implement this in the UWP/full-trust app, registration fails with E_INVALIDARG. According to MSDN, this can be because the source or destination windows are not top-level windows. In this case, the destination window is the window handle for the UWP app, and the source window is explorer.exe (file explorer, in this case). Both are enumerated by EnumWindows and aren't children of other windows.
Is the problem that the full-trust side is calling DwmRegisterThumbnail? I tried making the calls from the UWP side as well, but got the same result. I wouldn't really expect to be able to make those calls from the UWP side anyway, since it would seem to violate the sandboxed nature of it. Is there any way to do this?
Edit:
I tried doing a C++ UWP proof-of-concept, but couldn't reference anything DWM-related. Then I found this. Looks like DWM isn't available at all to UWP.
I'm guessing the full-trust component can't register the UWP app to be drawn to because, according to this:
The window designated by hwndDestination must either be the desktop
window itself or be owned by the process that is calling
DwmRegisterThumbnail. This is required to prevent applications from
affecting the content of other applications.
As stated above, I tried having the full-trust component call DwmRegisterThumbnail, using the handle of the host UWP app, but it doesn't appear to work, presumably because it isn't owned by the UWP process?
Does anyone know of alternative methods that could be used to accomplish a thumbnail/window preview?

Toast Notifications does not appear in Action Center after time out

Toast notification in Windows 10 is behaving strange. It does not stay in the action center even if user has not taken any actions yet. This behavior is with custom notification and generic both. Toast notification is generated using a Windows desktop application not using a universal window.
As answered here :
Win32 apps need to set up a COM server in order to have toasts persisted in Action Center: http://blogs.msdn.com/b/tiles_and_toasts/archive/2015/10/15/quickstart-handling-toast-activations-from-win32-apps-in-windows-10.aspx
You can go on https://github.com/WindowsNotifications/desktop-toasts to view some working samples in C++ and C#.

Screensaver app on Windows Phone 8.1

I would like to create an app which would pop-up fullscreen when user is not interacting with the device; the first tap would then close it. So it's exactly like a screensaver. It should "run" 24/7. Display should always be lit. Battery is of no concern.
I've already done this on android, but my WP skills are lacking and complete research would take me at least a couple of days, so I'm asking any WP gurus out there:
can the same functionality (screensaver) be achieved on the Windows Phone 8.1 platform?
If so, which are the basics that should be covered (programming-wise)?
Edit:
The only solution I have at this moment is changing the LockScreen background on a 30minute interval.
I'm still not sure whate happens in 2 weeks as some info suggests that the registered task will expire. Not to mention that LockScreen is shown only a few seconds.
Edit 2:
Subquestion: is there a way to keep LockScreen shown at all times (while charging)? Or maybe lauch lock screen from code?
Windows Phone doesn't usually allow apps to pop up on their own. Exceptions are made for specific usecases such as voip. There is also no way for an app that isn't running in the foreground to realise that the user hasn't interacted with the screen for any number of minutes.
Therefore your only option is to use the inbuilt lockscreen functionality.

Wp7 push notification to launch my app

As far as I know, Ios and Android gcm are able to open an application when a push notification event arrives.
For wp7, I only find samples on how to update tiles or display a message. But I need to display a bitmap in fullscreen.
Is there a way to open my app when I send a push notification ?
Thanks in advance for your help.
There is no way you can launch anything via a push notification on Windows Phone. Raw, toast and tile are the only acceptable types, none of which is able to invoke code execution outside the pre-defined boundaries (e.g. launch the app when the toast is tapped).
Since you are displaying an image, your best bet would be focusing on the tile updating mechanism. Remember, however, that there are no guarantees that the user will see the tile (unless pinned), or keep it on the home screen permanently.
If you send a Toast notification using the Notification mechanism, then tapping on the Toast will launch the application, you can then specify a page to navigate to within your application.
Take a look at the following for more information :
http://msdn.microsoft.com/en-us/library/hh202967(v=vs.92).aspx

Categories