Search code examples
c#azurewindows-8push-notification

Hiding the Toast Notification when a push notification is received


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.


Solution

  • 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;