I am using Windows azure push notifications. Every time a new notification is received a Toast is displayed with the information received, is there anyway I can disable this feature programmatically? The reason I want this is because I am trying to develop a FPS game and I am using the Push notifications to update locations, for obvious reasons I don't want the data received to get displayed.
You can hide the toast notification by setting the expiration time of the ToastNotification to DateTime.Now, that way it would expire as soon as it is displayed. You can do that by using the PushNotificationReceivedEventArgs args that is passed.
args.ToastNotification.ExpirationTime = DateTime.Now;
A better solution as provided by Gaurav is to use
args.Cancel=true;
What you could do is consume the PushNotificationReceived event and then handle it there. I did the same for one sample chat application I built. Look for the code for app.xaml.cs in my blog post here: http://gauravmantri.com/2012/08/30/how-i-built-an-awesome-chat-application-for-windows-8-with-windows-azure-mobile-service/.
Related
I need to update my SQLite database with details sent via an online MVC application which sends a firebase data message to the Xamarin Application linked to the specific user's profile
While the app is in the foreground I can update the database directly with the details contained within the firebase data message.
The problem is that I need the database to be updated whilst the application is in a closed state so when they open it the UI and data states are already built and ready for the user (Without having to then do an HTTP request to get any new information)
Through my workings, I have seen that I must use a Firebase.Jobdispatcher...however I see that it seems to have been deprecated.
public override void OnMessageReceived(RemoteMessage message)
{
base.OnMessageReceived(message);
//Custom message received
if (IsApplicationInTheBackground())
{
//The send notification sends the push notification no problem
SendNotification(message.GetNotification().Body, message.Data);
//I wish to add specific code to write to the SQLite here
} else
{
//Notify within the application using snackbar
var mA = new MessageAndroid();
mA.ShortAlert(message.GetNotification().Body);
var uti = new FindMyDriver(); //Location pin pointing request
uti.ReturnLocationAsync(message.GetNotification().Body);
}
}
In the block where it states "I wish to add specific code .." I would like to save specific details about the loads that have been sent from the MVC application to the linked user App on a registered phone.
I would like to call a specific void to run whilst the App is offline/background.
Is this at all possible with all the controls on services etc lately?
The big issue above was that the FCM didn't actually fire the OnMessageReceived event.
This was due to the FCM being received as a notification and not as a data payload. Once I changed the payload to data it worked 100% allowing me to initialize a foreground service and run from there.
I have used the Microsoft Bot Framework Proactive Message samples which are great but I have one issue.
In the simple message example (https://github.com/Microsoft/BotBuilder-Samples/tree/master/CSharp/core-proactiveMessages/simpleSendMessage) the messages send but in Facebook Messenger I don't get a notification on my phone. However, adding in this simple bit of code fixes that perfectly:
message.ChannelData = JObject.FromObject(new { notification_type = "REGULAR" });
I'm now using the Start New Dialog example (https://github.com/Microsoft/BotBuilder-Samples/tree/master/CSharp/core-proactiveMessages/startNewDialog) and want to do the same thing but the dialog messages do not cause a notification. I've tried setting the notification_type in as above in various places in my code but nothing seems to work.
Any help / pointers would be greatly appreciated.
Thanks
Stu
I've found the notifications work just fine without any code changes to the Start New Dialog example sample since making my Messenger Bot Public. I don't understand why some notifications work / don't work when the bot is not public.
I need some help to find a good pattern for a custom application insights metric.
Environment
I have a custom Windows Service running on multiple Azure VMs.
I can successfull add Events to my Monitoring instance on Azure.
Goal
I want to create a custom metric that allows me to monitor if my windows services are running and responding per instance. It would be perfect if it acts like the respond timeout in website metric.
Each service instance has a custom maschine related identifier, like:
TelemetryClient telemetry = new TelemetryClient();
telemetry.Context.Device.Id = FingerPrint.Instance;
Now I wnat to create a alert if one of my Service instances (Context.Device.Id) is not running or responding.
Question
How to achive this?
Is it even possible or usefull to Monitor multiple instance of one service type onside on application insight? Or must I open one single application insight per instance?
Can anybody help me?
Response to Paul's answere
Track Metric Use TrackMetric to send metrics that are not attached to particular events. For example, you could monitor a queue length at regular intervals.
If I do so, whats happens if my server made a restart (update or somethink) and my service don't start up. Now the service did't send a TrackMetric to the application insight and no alert is raised because the value don't drop below 1, but the Service is still not running.
Regards Steffen
I found a good working solution, with only a few simple steps.
1) Implement a HttpListener instance on a service port (for example 8181) with a simple text response "200: OK"
2) Add a matching endpoint to the azure VM imstande
3) Create a default web test on "myVM.cloudapp.net:8181" with checkup of response text
Work great so far and matches all my needs! :)
Per the documentation on Azure portal:
https://azure.microsoft.com/en-us/documentation/articles/app-insights-api-custom-events-metrics/#track-metric
Track Metric
Use TrackMetric to send metrics that are not attached to particular events. For example, you could monitor a queue length at regular intervals.
Metrics are displayed as statistical charts in metric explorer, but unlike events, you can't search for individual occurrences in diagnostic search.
Metric values should be >= 0 to be correctly displayed.
c# code looks like this
private void Run() {
var appInsights = new TelemetryClient();
while (true) {
Thread.Sleep(60000);
appInsights.TrackMetric("Queue", queue.Length);
}
}
I don't think there is currently a good way to accomplish this. What you're actually looking for is a way to detect a "stale heartbeat." For example, if your service was sending up an event "Service Health is okay", you'd want an alert that you haven't received one of those events in a certain amount of time. There aren't any date/time conditional operators in AI's alert system.
Microsoft might explain that this scenario is not intended to be satisfied by AI, as this is more of a "health checking" system's responsibility, like SCOM or Operation Insights or something else entirely.
I agree this is something that needs a solution, and using AI for it would be wonderful (I've already attempted to accomplish the same thing with no luck); I just think "they" will say its not a scenario in the realm of responsibility for AI.
I would like to create an alarm app.
I found the way of operating a timer in the background. But APIs which control the power of the display were not found(I want to turn on the display's power when its power is off).
Doesn't Windows 10 (Windows Universal App) have enough APIs to create that app?
Windows-universal-samples has recently been updated with a few new RTM samples including this one - Notifications.
As Alarm is also one type of notification, it's now built within a new toast notification framework in the Universal Windows Platform.
After you downloaded the source code from the Notification's link above, run it with Visual Studio 2015 RTM and then once the app is loaded, go to
toasts > scenarios > scenario: alarm
and you will see a fully functional alarm app (along with Reminder and a lot other samples).
Let's talk about code.
Basically, unlike in Windows Phone Silverlight, you can now customise the alarm popup a bit by specifying the xml payload like this (make sure the scenario is set to alarm)
<toast launch='args' scenario='alarm'>
<visual>
<binding template='ToastGeneric'>
<text>Alarm</text>
<text>Get up now!!</text>
</binding>
</visual>
<actions>
<action arguments = 'snooze'
content = 'snooze' />
<action arguments = 'dismiss'
content = 'dismiss' />
</actions>
</toast>
And then create an XmlDocument which loads the above xml string
var xmlString = #"//copy above xml here//";
var doc = new Windows.Data.Xml.Dom.XmlDocument();
doc.LoadXml(xmlString);
Then create a ToastNotification and trigger it with ToastNotificationManager-
var toast = new ToastNotification(doc);
ToastNotificationManager.CreateToastNotifier().Show(toast);
That's it! You will see an alarm popup like below.
Update
Microsoft recently responded to one of my API requests and I am posting the content here so everyone knows what APIs have been added and what are still outstanding.
What has been done
There is now a way to create an alarm/reminder in universal windows
apps;
The alarm/reminder supports custom snooze time (you can choose to
let system handle snooze, or wake up your background task to do it
manually);
The alarm/reminder supports vibrate only (just like toast) that can
be overwritten by user to turn off vibration;
The alarm/reminder supports a good level of customizability (custom
optional inline image, custom additional actions, etc).
Some references
Adaptive and interactive toast notifications for Windows 10
Toast Notification and Action Center Overview for Windows 10
Quickstart: Sending a local toast notification and handling
activations from it (Windows 10)
What we (MSFT) know that’s missing and hope to support in the near future
Native platform support in alarm/reminder to automatically handle time conversion when time-zone changes (Workaround – this can be done by the app manually by using the TimeZoneChange system trigger);
Native platform support in alarm/reminder for recurrence events (Workaround – this can currently only be done by the app manually periodically waking up and reschedule a bunch of alarms/reminders ahead of time);
Native platform support to select a song from Music library as ring tone for alarm/reminder (Workaround – this can be done by reading and copying files from your music library, and then use the saved/modified version of the file in your app package or app data as the ring tone (toast notification supports custom sound by pointing to files in appx or appdata in the xml payload)).
AlarmApplicationManager can be used to create alarm apps. It gives capabilities to schedule toast notifications.
var scheduledToast = new ScheduledToastNotification(content, DateTime.Now.AddMinutes(5));
toastNotifier.AddToSchedule(scheduledToast);
An audio source can also be set while creating the toast template, but only from a set of predefined sounds supplied by windows.
Refer AlarmApplicationManager and Building alarm app for more details.
There are a number of Win 10 Universal Samples on GitHub which may be useful. I didn't see anything directly related to Alarms, though.
unfortunately Windows Universal Applications have no direct access to the Display Settings. But you can use the AlarmApplicationManager Class to create an Alarm. This will, in some cases (for sure on WindowsPhone) turn on the display automatically to show off the Alarm (with Title and Description).
Is there a way to get the current count of Tile notifications on Windows Phone and update it locally. I need to update the tile count locally if I have read a notification via push notification / toast without hitting the push service from the server end.
Say for eg. I have the tile count 6. As soon as I receive a push notification and I click on it, I want the tile count to be reduced by 1. How do I achieve this?
Unfortunately you cannot read out information from a ShellTile. You can only update them.
What you could do is saving the information of the counter or anything else on your server that pushes. It can preperate the notification as you wish. I guess this is not the way you want to deal with it but it is the only way.