locked
Intercept ScheduledToastNotification

    Question

  • http://msdn.microsoft.com/en-us/library/windows/apps/hh465391.aspx

    This page indicates that toast notifications can be intercepted using the `PushNotificationReceived` event.  So I put this into my App.xaml.cpp

    create_task(PushNotificationChannelManager::CreatePushNotificationChannelForApplicationAsync())
    .then([this](PushNotificationChannel ^channel) {
    	channel->PushNotificationReceived += ref new TypedEventHandler<PushNotificationChannel ^, PushNotificationReceivedEventArgs ^>
    (this, &App::OnPushNotification);
    });

    I then schedule a notification like so

    ToastNotificationManager::CreateToastNotifier()->AddToSchedule(notification);

    However, the toast shows even when the app is in the foreground (the event handler is never called).  Why is this?  Perhaps the channel is only for remote push notifications?  In that case, is there a similar way to intercept locally scheduled notifications?  Or do I have to remove them when the app is in the foreground, and add them when it goes into the background?

    Friday, July 11, 2014 4:36 AM

Answers