locked
Background Task - Debugging and Toast issues RRS feed

  • Question

  • I'm looking for some guidance into an odd issue I have with a background task.

    - The background task is triggered by push notifications

    - inside the task I perform a tile update.  This works fine

    - What doesn't work is the following:

      - my breakpoints will not get triggered

      - Debug.WriteLine will not output anything to the console (works fine outside of the task)

      - I cannot display a toast notification.  (this works fine if called outside of the task)

    Any leads would be appreciated~

    Wednesday, October 24, 2012 12:31 AM

Answers

  • Thanks Sara for the suggestion.  Didn't quite solve my issue, but I think I have this kind of figured out now.   My main issues were mainly stemming from some misunderstandings.  What I realize now (which wasn't clear to me before) was:

    - background tasks do not get activated by regular tile/toast push notifications.  Only raw notifications.  And for these, yes the app must be a lockscreen app.

    - for regular tile/toast push notifications, an app does not need to be a lockscreen app.  Hence why Messenger and other sample apps pop up toasts just fine.

    • Marked as answer by Aaron Xue Friday, November 9, 2012 8:56 AM
    Friday, October 26, 2012 11:53 PM

All replies

  •  I cannot display a toast notification.  (this works fine if called outside of the task) => did you maked your application Toast Capable on the first tab of the application manifest?
    Wednesday, October 24, 2012 5:20 AM
  • Yes the manifest was configured properly.   Without that setting, the toast notification would not work outside the background task.  With it on, it works, but just not within a background task.
    Wednesday, October 24, 2012 4:19 PM
  • fyi just an update, I suspect there is something different/wrong with the project I'm working with (essentially its hacked up from the Win8 SDK Sample for Push and Periodic Notifications in C#).  Working with the SDK Background Task sample app, I have no problems debugging or invoking toast notifications from within the background task.

    Wednesday, October 24, 2012 5:36 PM
  • OK, revisited push notifications with the Background Task Sample app, here are my findings and some questions:

    - As it turns out, my breakpoint in my background task will not get called (and Debug.WriteLines will not output) when the background task is invoked by an actual push notification.   These work fine if the task is invoked by the debug menu or triggered by a system notification.   So the question is, how do I debug push notifications in real time?

    - "Introduction to Background Tasks" indicate that for push notifications to work, the background task must be on the lockscreen.  This is not what I'm seeing.   I am able to see Toast notifications coming from the Messaging app and my sample apps, neither of which are on the lock screen.   Is the documentation incorrect?

    - From within a background task that is triggered by a push notification, I would like to programmatically invoke either a toast or tile notification.   Regardless of the push notification type (raw/tile/toast), this does not work for me.   Again, if the background task is triggered by other means (system notification, debug menu) its fine.   Is there some sort of limitation imposed on background tasks that are triggered by push notifications?

    Thursday, October 25, 2012 8:50 PM
  • Did you see this:


    Sara Silva
    My Windows 8 Store Apps Samples
    Follow me in Twitter @saramgsilva

    My Windows 8 Store Apps: Female Pill | Galinho (Tic tac Toe) | 24
    (If my reply answers your question, please propose it as an answer because it will help other users)

    Thursday, October 25, 2012 10:24 PM
  • Thanks Sara for the suggestion.  Didn't quite solve my issue, but I think I have this kind of figured out now.   My main issues were mainly stemming from some misunderstandings.  What I realize now (which wasn't clear to me before) was:

    - background tasks do not get activated by regular tile/toast push notifications.  Only raw notifications.  And for these, yes the app must be a lockscreen app.

    - for regular tile/toast push notifications, an app does not need to be a lockscreen app.  Hence why Messenger and other sample apps pop up toasts just fine.

    • Marked as answer by Aaron Xue Friday, November 9, 2012 8:56 AM
    Friday, October 26, 2012 11:53 PM